[Bug c++/36852] Two dimensional array in template method argument list incorrectly interpreted.
djh at emss dot co dot za
gcc-bugzilla@gcc.gnu.org
Thu Jul 17 12:48:00 GMT 2008
------- 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
More information about the Gcc-bugs
mailing list