This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug report: internal compiler error on a throw statement


Hello everyone,

I have found an internal compiler error.

The following program:
=-=-=-=-=-=-=-=
class Exception {
public:
    Exception() {}
};

class Exception2: public Exception {
public:
    Exception2() {}
    virtual ~Exception2() {}
};

template<class T> class X {
public:
    X() { }
    void Bad() { throw Exception2(); }
};

int main()
{
    X<int> A;
    A.Bad();
    return 0;
}
=-=-=-=-=-=-=-=

Causes the following internal compiler error:

> g++ -Wall t.cc
t.cc: In method `Exception2::Exception2(const class Exception2 &)':
t.cc:15: Internal compiler error 980521.
t.cc:15: Please submit a full bug report to `egcs-bugs@cygnus.com'.
Exit 1


I use the following compiler version:

> g++ -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.50/specs
gcc version egcs-2.91.50 19980714 (gcc2 ss-980609 experimental)

I know there is a more recent snapshot, but since I guess there will be
a new snapshot within days, I didn't bother to install it.

To get the ICE it is essential that the flag '-Wall' is set (I haven't
bothered to narrow down the guilty warning flag, sorry), that Exception2
inherits, that Exception2 has a destructor, and that X is a template
class.

Also, when X is not a template class, but an ordinary class, the 'throw'
statement causes the warning 'statement has no effect', which looks odd
to me.

-- 
Kees van Reeuwijk, Delft University of Technology
http://pds.twi.tudelft.nl/~reeuwijk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]