This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25337] New: ICE with template processing
- From: "halcy0n at gentoo dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Dec 2005 06:20:43 -0000
- Subject: [Bug c++/25337] New: ICE with template processing
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is a testcase that results in an ICE:
#include <iostream>
typedef char present_t;
typedef struct { char a[2]; } absent_t;
template <typename T> T& MakeT();
template <typename T>
struct test
{
// template <typename U, int (U::*f)(int n) = &U::operator[]>
// struct helper{};
template <typename U, int N = sizeof (MakeT<U>().operator[](0))>
struct helper{};
template <typename U>
static absent_t is_here(...);
template <typename U>
static present_t is_here(helper<U>*);
enum { ret = (sizeof(is_here<T>(0)) == sizeof(present_t)) };
};
struct A { };
struct B { int operator[](int n) { return n; } };
struct X : public A { };
struct Y : public B { };
int main()
{
std::cout << "A has [] : " << test<A>::ret << std::endl;
std::cout << "B has [] : " << test<B>::ret << std::endl;
std::cout << "X:A has [] : " << test<X>::ret << std::endl;
std::cout << "Y:B has [] : " << test<Y>::ret << std::endl;
}
The commented out block is the version of helper that doesn't cause the ICE,
while the second does. This is broken on 3.4.4, 4.0.2, 4.1.0. Works with
3.3.6.
--
Summary: ICE with template processing
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: halcy0n at gentoo dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25337