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]

ICE191, simplified testcase


I have reduced the size of the source which reproduces this ICE, which I
reported May 26.  I hope this will make the problem more attractive for
egcs-developers.

Thanks for a great compiler!

(The code uses a small trick to determine (compile time) wether a class
is derived from another class.  If the inheritance is double, including
a virtual inheritance, compilation fails.  The code works for simpler
cases of inheritance, and I can't see any reason why the code should be
invalid.)


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

-------> uname -a
Linux katsumoto.matfys.lth.se 2.0.34 #1 Fri May 8 16:05:57 EDT 1998 i586
unknown

-------> g++ ice191.cc
ice191.cc: In instantiation of `is_a_<doubly_derived,base>::size':
ice191.cc:22:   instantiated from `is_a_<doubly_derived,base>'
ice191.cc:22:   instantiated from here
ice191.cc:12: Internal compiler error 191.
ice191.cc:12: Please submit a full bug report to `egcs-bugs@cygnus.com'.

-------> cat ice191.cc

struct nulltype {};
struct truetype {};

template <class T> inline char _is_a_1(const void*) {}
template <class T> inline long _is_a_1(const T*) {}

template <int N> struct is_longsize_ { typedef nulltype eval; };
template <> struct is_longsize_<sizeof(long)> { typedef truetype eval;
};

template <class T, class U> struct is_a_ {
    static const int size = sizeof(_is_a_1<U>(static_cast<T*>(0)));
    typedef typename is_longsize_<size>::eval eval;
};
template <class T, class U> const int is_a_<T, U>::size;

struct base {};
struct virtual_derived : virtual public base {};
struct doubly_derived : public virtual_derived {};

int main(int, char**) {
    typedef typename is_a_<doubly_derived, base>::eval res;
}


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