469,628 Members | 1,077 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

[BUG] ICE cause by template class with constructor-like declaration with name of different class and template const parameters

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.

--
Sven Groot

http://unforgiven.bloghorn.com

Nov 17 '05 #1
3 1473
Sven Groot wrote:
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.


I forgot to mention that this happens in Visual Studio .Net 2003.

--
Sven Groot

http://unforgiven.bloghorn.com
Nov 17 '05 #2
Sven Groot wrote:
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.
I guess I'm the official VC++ bug reporter now ;-) (seriously though -
there's lots of people, including VC team members, that read this NG and can
handle this kind of thing just as well as I).
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.
I'm quite sure this is a known bug. Of course, in the ideal world, nothing
should result in an ICE. In this case, the code is ill-formed, and at least
according to the standard, an ICE is just as valid a message from the
compiler as a "proper" error message would be. Of course, to end-users, the
story is different!
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.


The code is ill-formed with or without the const. Note that "implicit int",
which VC supports, but which is not a part of the C++ standard, confuses
situations like this quite a bit.

-cd
Nov 17 '05 #3
Thanks Sven for reporting the issue. It could be a known issue but I logged
it as issue# 583177 anyways.

I also made sure that it is currently fixed using the most recent compiler
builds. With the current compiler bits, meaningful erros are reported.

--------------------
| From: "Sven Groot" <sv*******@gmx.net>
| Subject: [BUG] ICE cause by template class with constructor-like
declaration with name of different class and template const parameters
| Date: Thu, 6 May 2004 21:47:15 +0200
| Lines: 55
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2120
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2120
| Message-ID: <#4**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vc
| NNTP-Posting-Host: 26-192.surfsnel.dsl.internl.net 145.99.192.26
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vc:36535
| X-Tomcat-NG: microsoft.public.dotnet.languages.vc
|
| 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.
|
| --
| Sven Groot
|
| http://unforgiven.bloghorn.com
|
|
--
Ayman Shoukry, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Luke | last post: by
reply views Thread by gary lim | last post: by
14 posts views Thread by Klaus Löffelmann | last post: by
16 posts views Thread by Edward Diener | last post: by
9 posts views Thread by fabio.bizzetti | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.