Bug 8031 - ICE in comptypes, at cp/typeck.c:913
Summary: ICE in comptypes, at cp/typeck.c:913
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P2 critical
Target Milestone: ---
Assignee: Gabriel Dos Reis
Keywords: ice-on-invalid-code
: 7994 (view as bug list)
Depends on:
Reported: 2002-09-25 03:46 UTC by Václav Haisman
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host: i386-unknown-freebsd4.6
Target: i386-unknown-freebsd4.6
Build: i386-unknown-freebsd4.6
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Václav Haisman 2002-09-25 03:46:03 UTC
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.

3.3 20020925 (experimental)

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

#include <typeinfo>

class A {
    virtual bool f(const A* a) = 0;

class B : virtual public A {
    char ch;
    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;
Comment 1 Kriang Lerdsuwanakij 2002-09-26 08:09:49 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.  The code is illegal, dynamic_cast should be used instead of static_cast.
Comment 2 Volker Reichelt 2002-10-27 17:54:45 UTC
From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, V.Haisman@sh.cvut.cz, gcc-bugs@gcc.gnu.org,
Subject: Re: c++/8031: ICE in comptypes, at cp/typeck.c:913
Date: Sun, 27 Oct 2002 17:54:45 +0200

 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.
Comment 3 Gabriel Dos Reis 2002-12-13 13:13:01 UTC
Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-Why: Working a fix.
Comment 4 Gabriel Dos Reis 2002-12-13 14:06:02 UTC
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.