Bug 26455 - g++ 3.x ICE on typeid(typeid(*object))
Summary: g++ 3.x ICE on typeid(typeid(*object))
Status: RESOLVED DUPLICATE of bug 26417
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-24 12:25 UTC by David Decotigny
Modified: 2006-02-24 18:30 UTC (History)
5 users (show)

See Also:
Host: i486-pc-linux-gnu
Target: i486-pc-linux-gnu
Build: i486-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Code leading to ICE (213 bytes, text/x-c++src)
2006-02-24 12:38 UTC, David Decotigny
Details
Preprocessor output (gcc 3.4.4) (781 bytes, text/plain)
2006-02-24 12:40 UTC, David Decotigny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Decotigny 2006-02-24 12:25:23 UTC
The code below generates an ICE with g++ 3.3 (debian stable),
g++ 3.4 (debian testing):

------------------------------------------------
[pollindd] ~ >g++-3.3 -c ice-typeid.cc
ice-typeid.cc: In function `int bug5(BaseB*)':
ice-typeid.cc:43: internal compiler error: in expand_expr, at expr.c:8833
Please submit a full bug ...

[pollindd] ~ >g++-3.4 -c ice-typeid.cc
ice-typeid.cc: In function `int bug5(BaseB*)':
ice-typeid.cc:43: internal compiler error: in expand_expr_real, at
expr.c:8469
Please submit a full bug report...
------------------------------------------------

It works well with g++ 2.95.4 (debian).
Maybe related to bug #25357.

------------------------------------------------
[pollindd] ~ >g++-3.4 -v
Reading specs from /usr/lib/gcc/i486-linux/3.4.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror i486-linux
Thread model: posix
gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13)

[pollindd] ~ >g++-3.3 -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.6/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.6 (Debian 1:3.3.6-5)
------------------------------------------------

Code follows. Command line:
  g++-3.x -c ice-typeid.cc
Optimisation flag seems to have no impact (same problem with
-O3). Likewise for -Wall. It works on more complicated code (?!)... but it's hard to see where the fix is introduced.

------------------------------------------------
#include <typeinfo>

class BaseB
{
public:
  virtual ~BaseB() {}
};

#if BUG == 1

const char* bug1(BaseB const* o)
{
  return typeid(typeid(*o)).name();
}

#elif BUG == 2

const std::type_info & bug2(BaseB const* o)
{
  return typeid(typeid(*o));
}

#elif BUG == 3

const char* bug3(BaseB * o)
{
  return typeid(typeid(*o)).name();
}

#elif BUG == 4

const std::type_info & bug4(BaseB * o)
{
  return typeid(typeid(*o));
}

#else

int bug5(BaseB * o)
{
  int i;
  return (typeid(typeid(*o)) == typeid(i));
}

#endif
------------------------------------------------
Comment 1 David Decotigny 2006-02-24 12:38:15 UTC
Created attachment 10907 [details]
Code leading to ICE

Compile it with -DBUG=xyz to activate bug xyz
Comment 2 David Decotigny 2006-02-24 12:40:30 UTC
Created attachment 10908 [details]
Preprocessor output (gcc 3.4.4)
Comment 3 Andrew Pinski 2006-02-24 18:30:47 UTC

*** This bug has been marked as a duplicate of 26417 ***