Mail Archives: cygwin/2000/09/08/07:49:05
------=_NextPart_000_001F_01C01992.AC796390
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> -----Original Message-----
> From: Chris Faylor [mailto:cgf AT cygnus DOT com]
> Sent: 07 September 2000 17:01
> To: Gnuwin
> Cc: kris DOT thielemans AT csc DOT mrc DOT ac DOT uk
> Subject: Re: problem with dynamic_cast
>
>
> This is a c++ problem. You should probably report this to a c++
> mailing list.
I doubt it really, but I send this to a C++ mailing list anyway. I've been
able to boil it down to something really simple. If the latest gcc
distribution is that broken, we're all in trouble.
Summarising: in cygwin 1.1.4, or the gcc (or ld) distributed with it (I've
installed 1.1.4 yesterday), there is a conflict with using RTTI and using
the math library.
Attached is a VERY simple C++ program that uses RTTI, but nothing else.
Compile it with
g++ dynamic_cast.cxx -lm
When you run it, it crashes in the dynamic_cast statement. On the other
hand, compile it with
g++ dynamic_cast.cxx
-> it runs fine (i.e. does essentially nothing).
More details:
I'm running NT 4.0 sp5 and cygwin 1.1.4.
screendump of running g++ -v:
$ g++ dynamic_cast.cxx -lm -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/specs
gcc version 2.95.2 19991024 (release-2)
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/cpp.exe -lang-c++ -v -D__GNUC__=2 -D_
_GN
UG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Di386 -D_X86=1 -D__STDC__=1 -D__st
dcal
l=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__decl
spec
(x)=__attribute__((x)) -D__i386__ -D_X86=1 -D__STDC__=1 -D__stdcall=__attrib
ute_
_((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attr
ibut
e__((x)) -D__i386 -Asystem(winnt) -Acpu(i386) -Amachine(i386) -D__EXCEPTIONS
-re
map -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiump
ro -
D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__CYGWIN32__ -D__CYGWIN
__ -
Dunix -D_WIN32 -DWINNT dynamic_cast.cxx /cygdrive/c/TMP/ccpF3zVU.ii
GNU CPP version 2.95.2 19991024 (release-2) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/../../../../include/g++-3
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/../../../../include
/usr/include
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/include/g++
/usr/X11R6.4/include
/usr/local/include
End of omitted list.
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/cc1plus.exe
/cygdrive/c/TMP/ccpF3zVU.ii
-quiet -dumpbase dynamic_cast.cc -version -o /cygdrive/c/TMP/ccKbIuaN.s
GNU C++ version 2.95.2 19991024 (release-2) (i686-pc-cygwin) compiled by GNU
C v
ersion 2.95.2 19991024 (release-2).
as -o /cygdrive/c/TMP/cc7g2nmV.o /cygdrive/c/TMP/ccKbIuaN.s
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/collect2.exe -Bdynamic
/usr/lib/crt0.o -
L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2
/cygdrive/c/TMP/cc7g2nmV.o -lstdc++ -lm
-lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
ld.dump attached is a screendump from running ld --verbose explicitly, after
removing as much libraries and options I could, while still reproducing the
crash.
gdb.dump is a screendump from running gdb on the file
------=_NextPart_000_001F_01C01992.AC796390
Content-Type: application/octet-stream;
name="dynamic_cast.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="dynamic_cast.cxx"
class A
{
public:
int a;
virtual ~A() {}
};
class B : public A
{
public:
int b;
};
class C : public B
{
public:
int c;
};
int f(const A* aptr)
{
if (const B* bptr =
dynamic_cast<const B *>(aptr))
{
return 0;
}
else
{
return 1;
}
}
int main()
{
C c;
return f(&c);
}
------=_NextPart_000_001F_01C01992.AC796390
Content-Type: application/octet-stream;
name="ld.dump"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="ld.dump"
GNU ld version 2.10.90 (with BFD 2.10.90)
Supported emulations:
i386pe
using internal linker script:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
OUTPUT_FORMAT(pei-i386)
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); =
SEARCH_DIR(/usr/i686-pc-cygwin/lib);
ENTRY(_mainCRTStartup)
SECTIONS
{
.text __image_base__ + __section_alignment__ :=20
{
*(.init)
*(.text)
*(SORT(.text$*))
*(.glue_7t)
*(.glue_7)
___CTOR_LIST__ =3D .; __CTOR_LIST__ =3D . ;=20
LONG (-1); *(.ctors); *(.ctor); LONG (0);=20
___DTOR_LIST__ =3D .; __DTOR_LIST__ =3D . ;=20
LONG (-1); *(.dtors); *(.dtor); LONG (0);=20
*(.fini)
/* ??? Why is .gcc_exc here? */
*(.gcc_exc)
etext =3D .;
*(.gcc_except_table)
}
/* The Cygwin32 library uses a section to avoid copying certain data
on fork. This used to be named ".data". The linker used
to include this between __data_start__ and __data_end__, but that
breaks building the cygwin32 dll. Instead, we name the section
".data_cygwin_nocopy" and explictly include it after __data_end__. =
*/
.data BLOCK(__section_alignment__) :=20
{
__data_start__ =3D . ;
*(.data)
*(.data2)
*(SORT(.data$*))
__data_end__ =3D . ;
*(.data_cygwin_nocopy)
}
.rdata BLOCK(__section_alignment__) :
{
*(.rdata)
*(SORT(.rdata$*))
*(.eh_frame)
}
.pdata BLOCK(__section_alignment__) :
{
*(.pdata)
}
.bss BLOCK(__section_alignment__) :
{
__bss_start__ =3D . ;
*(.bss)
*(COMMON)
__bss_end__ =3D . ;
}
.edata BLOCK(__section_alignment__) :
{
*(.edata)
}
/DISCARD/ :
{
*(.debug$S)
*(.debug$T)
*(.debug$F)
*(.drectve)
}
.idata BLOCK(__section_alignment__) :
{
/* This cannot currently be handled with grouped sections.
See pe.em:sort_sections. */
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
SORT(*)(.idata$4)
SORT(*)(.idata$5)
SORT(*)(.idata$6)
SORT(*)(.idata$7)
}
.CRT BLOCK(__section_alignment__) :
{ =09
*(SORT(.CRT$*))
}
.endjunk BLOCK(__section_alignment__) :
{
/* end is deprecated, don't use it */
end =3D .;
_end =3D .;
__end__ =3D .;
}
.rsrc BLOCK(__section_alignment__) :
{ =09
*(.rsrc)
*(SORT(.rsrc$*))
}
.reloc BLOCK(__section_alignment__) :
{ =09
*(.reloc)
}
.stab BLOCK(__section_alignment__) (NOLOAD) :
{
[ .stab ]
}
.stabstr BLOCK(__section_alignment__) (NOLOAD) :
{
[ .stabstr ]
}
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
attempt to open /usr/lib/crt0.o succeeded
/usr/lib/crt0.o
attempt to open dynamic_cast.o succeeded
dynamic_cast.o
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libstdc++.a =
failed
attempt to open /usr/lib/libstdc++.a succeeded
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libm.a failed
attempt to open /usr/lib/libm.a succeeded
(/usr/lib/libm.a)cygwin_crt0.o
(/usr/lib/libm.a)ds00024.o
(/usr/lib/libm.a)_cygwin_crt0_common.o
(/usr/lib/libm.a)ds00611.o
(/usr/lib/libm.a)dh.o
(/usr/lib/libm.a)ds00540.o
(/usr/lib/libm.a)ds00893.o
(/usr/lib/libm.a)ds00676.o
(/usr/lib/libm.a)ds00812.o
(/usr/lib/libm.a)premain3.o
(/usr/lib/libm.a)premain2.o
(/usr/lib/libm.a)premain1.o
(/usr/lib/libm.a)premain0.o
(/usr/lib/libm.a)ds00594.o
(/usr/lib/libm.a)dt.o
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a =
succeeded
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)_eh.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)tinfo.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)tinfo2.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)opdel.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)_ctors.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)frame.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)exception.o
(/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libgcc.a)_chkstk.o
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libcygwin.a =
failed
attempt to open /usr/lib/libcygwin.a succeeded
(/usr/lib/libcygwin.a)ds00820.o
(/usr/lib/libcygwin.a)ds01089.o
(/usr/lib/libcygwin.a)ds01004.o
(/usr/lib/libcygwin.a)ds00498.o
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libkernel32.a =
failed
attempt to open /usr/lib/libkernel32.a succeeded
(/usr/lib/libkernel32.a)ds00290.o
(/usr/lib/libkernel32.a)dh.o
(/usr/lib/libkernel32.a)dt.o
attempt to open /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/libadvapi32.a =
failed
attempt to open /usr/lib/libadvapi32.a succeeded
------=_NextPart_000_001F_01C01992.AC796390
Content-Type: application/octet-stream;
name="gdb.dump"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="gdb.dump"
(gdb) r
Starting program: /home/kris/C++/test-gcc/a.exe
Program received signal SIGSEGV, Segmentation fault.
0x80d0 in ?? ()
(gdb) info stack
#0 0x80d0 in ?? ()
#1 0x402054 in __si_type_info::dcast (this=3D0x4070f4, to=3D AT 0x4070e4,
require_public=3D1, addr=3D0x241fd90, sub=3D0x4070d4, =
subptr=3D0x241fd90)
at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76
#2 0x4022a3 in __dynamic_cast (from=3D0x4059c4 <C type_info function>,
to=3D0x405988 <B type_info function>, require_public=3D1, =
address=3D0x241fd90,
sub=3D0x405958 <A type_info function>, subptr=3D0x241fd90)
at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38
#3 0x40107a in f (aptr=3D0x241fd90) at dynamic_cast.cxx:25
#4 0x4010fc in main () at dynamic_cast.cxx:43
#5 0x61002272 in _size_of_stack_reserve__ ()
#6 0x61002805 in _size_of_stack_reserve__ ()
#7 0x61002843 in _size_of_stack_reserve__ ()
#8 0x40117d in cygwin_crt0 () at dynamic_cast.cxx:45
------=_NextPart_000_001F_01C01992.AC796390
Content-Type: text/plain; charset=us-ascii
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------=_NextPart_000_001F_01C01992.AC796390--
- Raw text -