public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Kris Thielemans" <kris.thielemans@ic.ac.uk>
To: "Gnuwin" <cygwin@sourceware.cygnus.com>
Cc: <gcc-bugs@gcc.gnu.org>
Subject: RE: problem with dynamic_cast
Date: Fri, 08 Sep 2000 04:48:00 -0000	[thread overview]
Message-ID: <001e01c0198a$4ab4fb90$460a10ac@petnt1.rpms.ac.uk> (raw)
In-Reply-To: <20000907120122.A22331@cygnus.com>

[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]

> -----Original Message-----
> From: Chris Faylor [ mailto:cgf@cygnus.com ]
> Sent: 07 September 2000 17:01
> To: Gnuwin
> Cc: kris.thielemans@csc.mrc.ac.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

[-- Attachment #2: dynamic_cast.cxx --]
[-- Type: text/x-c++, Size: 328 bytes --]


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);

}

[-- Attachment #3: gdb.dump --]
[-- Type: text/plain, Size: 921 bytes --]

(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=0x4070f4, to=@0x4070e4,
    require_public=1, addr=0x241fd90, sub=0x4070d4, subptr=0x241fd90)
    at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76
#2  0x4022a3 in __dynamic_cast (from=0x4059c4 <C type_info function>,
    to=0x405988 <B type_info function>, require_public=1, address=0x241fd90,
    sub=0x405958 <A type_info function>, subptr=0x241fd90)
    at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38
#3  0x40107a in f (aptr=0x241fd90) 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

[-- Attachment #4: ld.dump --]
[-- Type: text/x-asm, Size: 4541 bytes --]

GNU ld version 2.10.90 (with BFD 2.10.90)
  Supported emulations:
   i386pe
using internal linker script:
==================================================
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__  : 
  {
     *(.init)
    *(.text)
    *(SORT(.text$*))
    *(.glue_7t)
    *(.glue_7)
     ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
			LONG (-1); *(.ctors); *(.ctor); LONG (0); 
     ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
			LONG (-1); *(.dtors); *(.dtor);  LONG (0); 
     *(.fini)
    /* ??? Why is .gcc_exc here?  */
     *(.gcc_exc)
     etext = .;
    *(.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__) : 
  {
    __data_start__ = . ;
    *(.data)
    *(.data2)
    *(SORT(.data$*))
    __data_end__ = . ;
    *(.data_cygwin_nocopy)
  }
  .rdata BLOCK(__section_alignment__) :
  {
    *(.rdata)
    *(SORT(.rdata$*))
    *(.eh_frame)
  }
  .pdata BLOCK(__section_alignment__) :
  {
    *(.pdata)
  }
  .bss BLOCK(__section_alignment__) :
  {
    __bss_start__ = . ;
    *(.bss)
    *(COMMON)
    __bss_end__ = . ;
  }
  .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__) :
  { 					
    *(SORT(.CRT$*))
  }
  .endjunk BLOCK(__section_alignment__) :
  {
    /* end is deprecated, don't use it */
     end = .;
     _end = .;
     __end__ = .;
  }
  .rsrc BLOCK(__section_alignment__) :
  { 					
    *(.rsrc)
    *(SORT(.rsrc$*))
  }
  .reloc BLOCK(__section_alignment__) :
  { 					
    *(.reloc)
  }
  .stab BLOCK(__section_alignment__) (NOLOAD) :
  {
    [ .stab ]
  }
  .stabstr BLOCK(__section_alignment__) (NOLOAD) :
  {
    [ .stabstr ]
  }
}


==================================================
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

  reply	other threads:[~2000-09-08  4:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-07  8:52 Kris Thielemans
2000-09-07  9:02 ` Chris Faylor
2000-09-08  4:48   ` Kris Thielemans [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-09-08  7:21 Bernard Dautrevaux
2000-09-08  7:19 Fleischer, Karsten (K.)
2000-09-08  9:47 ` Chris Faylor
2000-09-08 20:01   ` Chris Faylor
2000-09-12  6:55     ` David Starks-Browning
2000-09-12  7:07       ` Chris Faylor
2000-10-04 15:20     ` Chris Faylor
2000-09-08  7:10 Earnie Boyd
2000-09-08  8:04 ` Kris Thielemans
2000-09-08  6:13 Fleischer, Karsten (K.)
     [not found] <B0016139757@mzdy10.allegro.net>
2000-09-08  5:56 ` Kris Thielemans
2000-09-08  4:58 Fleischer, Karsten (K.)
2000-09-08  6:56 ` Larry Hall (RFK Partners, Inc)
2000-09-08  7:04   ` Kris Thielemans
2000-09-08  7:16     ` Larry Hall (RFK Partners, Inc)
2000-08-31  8:01 Kris Thielemans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001e01c0198a$4ab4fb90$460a10ac@petnt1.rpms.ac.uk' \
    --to=kris.thielemans@ic.ac.uk \
    --cc=cygwin@sourceware.cygnus.com \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).