This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dynamic_cast of ostream


Hi folks,

the following program produces a segmentation fault

#include <iostream>

class A : public std::ostream {
public:

 A() : std::ostream(std::cout.rdbuf()) {}
};

A* test(std::ostream* os) {
 return dynamic_cast<A*>(os);
}

int main(int argc,char* argv[]) {
 std::cerr << (dynamic_cast<A*>(&std::cerr) == 0) << "\n";
 std::cerr << (test(&std::cerr) == 0) << "\n";
}
 

compiler: g++ 2.95.2
os: Linux Suse 6.3 on PIII 450 MHz

Regards, Peter Kelb

-- 
Dr. Peter Kelb                  phone:   (+49) 89 636 45890
Siemens AG, ZT SE 4             fax:     (+49) 89 636 42284
Otto-Hahn-Ring 6                e-mail:  Peter.Kelb@mchp.siemens.de
D-81739 Muenchen, Germany

-------------------------------------------------------------------

"As an adolescent I aspired to lasting fame, I craved factual
certainty, and I thirsted for a meaningful vision of human life
-- so I became a scientist.  This is like becoming an archbishop
so you can meet girls."
                        -- Matt Cartmill
 
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]