D
Danny Boelens
Hi all,
today I ran into a compile error after a compiler upgrade. I made a small
example to demonstrate my compile error:
template<typename T1, typename T2>
class A
{};
class B
{
static void f( const A<int,int>& inA = A<int,int>() )
{}
};
int main()
{
return 0;
}
This code compiles fine with Metrowerks CodeWarrior 8.3 (and also with
Microsoft Visual Studio 6 SP5 and the online "try it out" Comeau C++
compiler). After an upgrade to Metrowerks CodeWarrior 9.4, I faced a
compiler error. I tried to compile the code above with several versions of
gcc (2.95.3, 3.3.something and the new 4.0.0) and these give basically the
same compiler error as CW 9.4:
main.cpp:8: parse error before '>'
(line 8 is the line with the static function f and default argument)
Note that this is only a simplified example and the actual class B also
contains a bunch of members/member functions, class A actually uses T1 and
T2 etc...
I'm far from a C/C++ expert, and I still didn't figure out if this code
should compile or not (and why exactly it is not valid C++ in that case).
However, I noticed that replacing 'class B' with 'namespace B' -- at the
same time removing the ';' after the '}' of course -- fixes the compile
error in both gcc and CW9.4. So I'm still wondering what is going on here...
Thanks in advance for any help!
Best regards,
Danny Boelens
today I ran into a compile error after a compiler upgrade. I made a small
example to demonstrate my compile error:
template<typename T1, typename T2>
class A
{};
class B
{
static void f( const A<int,int>& inA = A<int,int>() )
{}
};
int main()
{
return 0;
}
This code compiles fine with Metrowerks CodeWarrior 8.3 (and also with
Microsoft Visual Studio 6 SP5 and the online "try it out" Comeau C++
compiler). After an upgrade to Metrowerks CodeWarrior 9.4, I faced a
compiler error. I tried to compile the code above with several versions of
gcc (2.95.3, 3.3.something and the new 4.0.0) and these give basically the
same compiler error as CW 9.4:
main.cpp:8: parse error before '>'
(line 8 is the line with the static function f and default argument)
Note that this is only a simplified example and the actual class B also
contains a bunch of members/member functions, class A actually uses T1 and
T2 etc...
I'm far from a C/C++ expert, and I still didn't figure out if this code
should compile or not (and why exactly it is not valid C++ in that case).
However, I noticed that replacing 'class B' with 'namespace B' -- at the
same time removing the ';' after the '}' of course -- fixes the compile
error in both gcc and CW9.4. So I'm still wondering what is going on here...
Thanks in advance for any help!
Best regards,
Danny Boelens