testcase-cast.cxx: In member function `virtual bool B::f(const A*)': testcase-cast.cxx:17: error: cannot convert from base `A' to derived type `B' via virtual base `A' testcase-cast.cxx:17: internal compiler error: in comptypes, at cp/typeck.c:913 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. Release: 3.3 20020925 (experimental) Environment: System: FreeBSD logout.sh.cvut.cz 4.6-STABLE FreeBSD 4.6-STABLE #0: Thu Aug 1 01:02:04 CEST 2002 root@logout.sh.cvut.cz:/usr/src/sys/compile/logout i386 host: i386-unknown-freebsd4.6 build: i386-unknown-freebsd4.6 target: i386-unknown-freebsd4.6 configured with: ../srcdir/configure --enable-threads --enable-languages=c,c++ --enable-version-specific-runtime-libs --prefix=/home/4/wilx --with-arch=i686 --with-cpu=i686 --enable-dwarf2 : (reconfigured) ../srcdir/configure --enable-threads --enable-languages=c,c++ --enable-version-specific-runtime-libs --prefix=/home/4/wilx --with-arch=i686 --with-cpu=i686 --enable-dwarf2 How-To-Repeat: #include <typeinfo> class A { public: virtual bool f(const A* a) = 0; }; class B : virtual public A { char ch; public: virtual bool f(const A* a); }; bool B::f(const A* a) { if (typeid(a) == typeid(B)) if (ch == static_cast<const B&>(*a).ch) return true; return false; }
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. The code is illegal, dynamic_cast should be used instead of static_cast.
From: Reichelt <reichelt@igpm.rwth-aachen.de> To: gcc-gnats@gcc.gnu.org, V.Haisman@sh.cvut.cz, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/8031: ICE in comptypes, at cp/typeck.c:913 Date: Sun, 27 Oct 2002 17:54:45 +0200 Hi, before the ICE g++ emits an error message, so that we'll see a "confused by earlier errors, bailing out" message instead in the release version (as in gcc 3.1 for example). However, gcc 3.0.x and gcc 2.95.x could handle this situation without such a message. So this is a slight regression. Greetings, Volker http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8031
Responsible-Changed-From-To: unassigned->gdr Responsible-Changed-Why: Working a fix.
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed with: 2002-12-13 Gabriel Dos Reis <gdr@integrable-solutions.net> PR C++/8031 * cvt.c (convert_to_pointer_force): Don't try comparing against erronous type.