------- Comment #2 from djh at emss dot co dot za  2008-07-17 12:47 -------
I have successfully reproduced this problem:

Create a header file with the following structure, saving it as "a.h":

class A
{
    public:
        template <class T> static T foo1(T [3][3]);
};

template <class T> T A::foo1(T t[3][3])
{
    return t[0][1];
}

Then compile it to precompiled header with GCC 4.3.1 using the following
command:"g++ -x c++-header -c a.h -o .obj/test.gch/c++"

Then create another file, say "test.cpp" that looks like this:

#include "a.h"
int main(int argc, char ** argv)
{
}

and then compile it using the following command:
"g++ -c test.cpp -include .obj/test"

This gives the output:
In file included from test.cpp:2:
a.h:1: error: redefinition of ‘class A’
a.h:2: error: previous definition of ‘class A’
a.h:8: error: prototype for ‘T A::foo1(T (*)[3])’ does not match any in class
‘A’

However, when I compile this with GCC 4.2.1 it has the following output:
In file included from test.cpp:2:
a.h:1: error: redefinition of ‘class A’
a.h:2: error: previous definition of ‘class A’
a.h:8: error: redefinition of ‘static T A::foo1(T (*)[3])’
a.h:8: error: ‘static T A::foo1(T (*)[3])’ previously declared here

As you can see GCC 4.3.1 does not match the foo1 method with any in the class. 
This is exactly the error that I am getting in our example.  This smaller
version thought, is obviously easy to fix: just add the #ifndef A, #define A
guard around the header file, and it works.  That solution thought does not
work for our real problem.


-- 

djh at emss dot co dot za changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED


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

Reply via email to