P
Paul Bibbings
I've been working on some code (not mine) that relies on the following
motif leading to a compilation failure, with sensible output, at line
17 (below). The trouble is, with gcc-4.4.3, it *doesn't* fail:
template<typename T>
struct Error { };
template<typename T>
struct A
{
static const int i = Error<T>::TempArgMustBeInt; // line: 7
};
template<>
struct A<int>
{ };
int main()
{
A<int> A_int;
A<char> A_char; // line: 17
}
I'm thinking that it probably should (or, I have no immediate
understanding of why it wouldn't); whoever wrote the original code
(probably some while ago) thought it should; and, Comeau seems to
agree:
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for
ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ noC++0x_extensions
"ComeauTest.c", line 7: error: class "Error<char>" has no member
"TempArgMustBeInt"
static const int i = Error<T>::TempArgMustBeInt;
^
detected during instantiation of class "A<T> [with T=char]" at
line 17
// ...
1 error detected in the compilation of "ComeauTest.c".
What does anyone else think?
Regards
Paul Bibbings
motif leading to a compilation failure, with sensible output, at line
17 (below). The trouble is, with gcc-4.4.3, it *doesn't* fail:
template<typename T>
struct Error { };
template<typename T>
struct A
{
static const int i = Error<T>::TempArgMustBeInt; // line: 7
};
template<>
struct A<int>
{ };
int main()
{
A<int> A_int;
A<char> A_char; // line: 17
}
I'm thinking that it probably should (or, I have no immediate
understanding of why it wouldn't); whoever wrote the original code
(probably some while ago) thought it should; and, Comeau seems to
agree:
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for
ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ noC++0x_extensions
"ComeauTest.c", line 7: error: class "Error<char>" has no member
"TempArgMustBeInt"
static const int i = Error<T>::TempArgMustBeInt;
^
detected during instantiation of class "A<T> [with T=char]" at
line 17
// ...
1 error detected in the compilation of "ComeauTest.c".
What does anyone else think?
Regards
Paul Bibbings