Hi, I have a tiny bit more information on this problem. - I reproduced it on my own NT box, with cygwin 1.1.4 (it does NOT happen with B20.1) - I can reproduce it with a file (attached) that does not need linking with any other file (except standard libs). * If I do a normal "g++ dynamic_cast8.cxx", the program runs fine * If I link it with another file I have "g++ dynamic_cast8.cxx bla.o" it crashes. The other file is also compiled with the same gcc (it's not specific to which file exactly). Weird. Suggestions ? Kris > -----Original Message----- > From: Kris Thielemans [ mailto:kris.thielemans@ic.ac.uk ] > Sent: 31 August 2000 15:58 > To: Gnuwin > Subject: problem with dynamic_cast > > > Hi, > > I have a problem with some of our own C++ software when compiled > with gcc on cygwin cygwin v.1.1.4 on Windows NT4.00.1381 (Finnish > language). Note that this program runs fine on my own NT 4.0 sp5 > or sp6 machines running cygwin B20.1 with gcc 2.95.2, and on > Solaris with gcc 2.95.2, and on AIX with gcc 2.8.1). > > The problem occurs when executing a dynamic_cast on a pointer. > Any suggestions ? > > > details: > --------- > The program generates the following error: > 0 [main] test_VoxelsOnCartesianGrid 1039 handle_exceptions: Exception: > STATUS_ACCESS_VIOLATION > 974 [main] test_VoxelsOnCartesianGrid 1039 stackdump: Dumping > stack trace > to test_VoxelsOnCartesianGrid.exe.stackdump > make: *** [run_tests] Segmentation fault (core dumped) > > The file where it crashes is compiled as follows: > g++ -g -D_DEBUG -g -Wall -I/home/PPhead/include -o > debug/VoxelsOnCartesianGrid.o -c VoxelsOnCartesianGrid.cxx > > > When running the program in gdb, the stack trace after the crash is: > Program received signal SIGSEGV, Segmentation fault. > 0x611e4 in ?? () > (gdb) info stack > #0 0x611e4 in ?? () > #1 0x41e484 in __si_type_info::dcast (this=0x460520, to=@0x4604c0, > require_public=1, addr=0xa057e90, sub=0x460280, subptr=0xa057e90) > at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76 > #2 0x41e6d3 in __dynamic_cast ( > from=0x441658 function>, > to=0x4415a4 , > require_public=1, address=0xa057e90, > sub=0x441544 , > subptr=0xa057e90) > at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38 > #3 0x40ddda in Tomo::find_sampling_and_z_size (z_sampling=@0x266f898, > s_sampling=@0x266f894, z_size=@0x266f89c, > proj_data_info_ptr=0xa057e90) > at VoxelsOnCartesianGrid.cxx:45 > #4 0x4325e8 in > Tomo::VoxelsOnCartesianGrid::VoxelsOnCartesianGrid ( > this=0x266fc00, proj_data_info=@0xa057e90, zoom=2.29999995, > origin=@0x266fd10, make_xy_size_odd=false) at > VoxelsOnCartesianGrid.cxx:138 > #5 0x4022a6 in Tomo::VoxelsOnCartesianGridTests::run_tests > (this=0x266fd60) > at test_VoxelsOnCartesianGrid.cxx:103 > #6 0x403174 in main () at test_VoxelsOnCartesianGrid.cxx:180 > #7 0x61002272 in _size_of_stack_reserve__ () > #8 0x61002805 in _size_of_stack_reserve__ () > #9 0x61002843 in _size_of_stack_reserve__ () > #10 0x41cdd5 in cygwin_crt0 () > > > This seems to say there is something wrong in the dynamic_cast > statement on that line, which looks as follows: > if (const ProjDataInfoCylindrical* > proj_data_info_cyl_ptr = > dynamic_cast(proj_data_info_ptr)) > { ...} > > By the way, if you check the stack trace, you'll see that the > dynamic cast is from a ProjDataInfoCylindricalArcCorr * to a > ProjDataInfoCylindrical *, where ProjDataInfoCylindricalArcCorr > is derived from ProjDataInfoCylindrical. (Not that it should > crash in any case). > > > Thanks ! > > > > Kris Thielemans > (kris.thielemans@ic.ac.uk) > MRC Cyclotron Unit, > Hammersmith Hospital, > DuCane Rd,London W12 0NN, United Kingdom > > Phone on : +44 (020)8383 3731 > FAX on : +44 (020)8383 2029 > > NEW web site address: > http://www.cu.mrc.ac.uk/~kris