http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48261

           Summary: internal compiler error: in lookup_template_function,
                    at cp/pt.c:6227
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: dta...@gmail.com


Created attachment 23762
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23762
File that GCC asked me to attach to this bug report.

Hi,
I encountered the compiler error:

internal compiler error: in lookup_template_function, at cp/pt.c:6227

I reproduced the error in a small test program:

----------------

struct Foo
{
template<typename T>
static T add(T a, T b)
{
return a+b;
}
};

double gadd(double a, double b)
{
return a+b;
}

typedef double (*gaddType)(double,double);
struct Foo2
{
static gaddType add;
};
gaddType Foo2::add=&gadd;


template<typename T>
struct Something 
{
void work()
{
double x=T::template add<double>(5.0,6.0);
}
};

int main()
{
Something<Foo> s;
s.work();

Something<Foo2> s2;
s2.work();
}

----------------

$ g++ a.cpp
a.cpp: In member function ‘void Something<T>::work() [with T = Foo2]’:
a.cpp:38:9:   instantiated from here
a.cpp:28:41: internal compiler error: in lookup_template_function, at
cp/pt.c:6227
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccj7WbC1.out file, please attach this to
your bugreport.


Admittedly the program doesn't make much sense but there still shouldn't be an
internal compiler error. Took me a while to figure out the cause of the problem
in my actual program.

I use GCC 4.5.1 (a friend also tried it on 4.5.2 with the same effect).
The file mentioned in the error message is attached to this bug report.

Thanks

Reply via email to