S
Sven Groot
This was posted by someone in comp.lang.c++, and later in
microsoft.public.vstudio.general, but since I know Carl is in this group,
and he's the one that should read this, I've reposted it here. I've also
minimalised the code that causes the bug.
The bug is that the following syntax causes an Internal Compiler Error. The
code is not correct, but should produce a warning or error message, not an
ICE. It occurs when a template class mistakenly names its constructor after
a different class, and in addition uses a template type parameter followed
by 'const'. See 'example below'. The code is complete.
----CODE SAMPLE----
class SomeClassA
{
};
template<typename X>
class SomeClassB
{
public:
SomeClassA(X const &n) { }; // *
};
int main()
{
return 0;
}
----END CODE SAMPLE----
----COMPILER OUTPUT----
test2.cpp
d:\My Documents\Visual Studio Projects\cpptest\test2.cpp(9) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
----END COMPILER OUTPUT----
The error occurs in the line marked // *. Remove the 'const' and the code
correctly fails to compile because it sees SomeClassA as a typename, but at
least in this situation it gives proper error messages, not an ICE. Remove
class SomeClassA, and the code compiles with "warning C4183: 'SomeClassA':
missing return type; assumed to be a member function returning 'int'".
Change the 'X' on line * into 'int', and the code compiles with the same
warning.
I'm not certain if code like this is supposed to compile according to the
standard with such a warning, or if it's supposed to fail like when the
const is removed, but I do know it shouldn't give an ICE.
microsoft.public.vstudio.general, but since I know Carl is in this group,
and he's the one that should read this, I've reposted it here. I've also
minimalised the code that causes the bug.
The bug is that the following syntax causes an Internal Compiler Error. The
code is not correct, but should produce a warning or error message, not an
ICE. It occurs when a template class mistakenly names its constructor after
a different class, and in addition uses a template type parameter followed
by 'const'. See 'example below'. The code is complete.
----CODE SAMPLE----
class SomeClassA
{
};
template<typename X>
class SomeClassB
{
public:
SomeClassA(X const &n) { }; // *
};
int main()
{
return 0;
}
----END CODE SAMPLE----
----COMPILER OUTPUT----
test2.cpp
d:\My Documents\Visual Studio Projects\cpptest\test2.cpp(9) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
----END COMPILER OUTPUT----
The error occurs in the line marked // *. Remove the 'const' and the code
correctly fails to compile because it sees SomeClassA as a typename, but at
least in this situation it gives proper error messages, not an ICE. Remove
class SomeClassA, and the code compiles with "warning C4183: 'SomeClassA':
missing return type; assumed to be a member function returning 'int'".
Change the 'X' on line * into 'int', and the code compiles with the same
warning.
I'm not certain if code like this is supposed to compile according to the
standard with such a warning, or if it's supposed to fail like when the
const is removed, but I do know it shouldn't give an ICE.