C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

vc8 bug?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Eugene Lazutkin
Guest





PostPosted: Tue Dec 13, 2005 11:26 pm    Post subject: vc8 bug? Reply with quote



I encountered a problem while switching from MSVC 7.1 to MSVC 8. I
was able to isolate it and reproduce it. Here it goes (obviously the real
code is not about arithmetics):

============================
#include <iostream>
using namespace std;

template< int I = 0 >
struct Helper
{
enum { RESULT = I };
template< int J > struct Add : public Helper< RESULT + J > {};
};

int main()
{
typedef Helper<>
::Add<1>
::Add<2>
::Add<3>
Result;
cout << Result::RESULT << endl;
return 0;
}
============================

MSVC 7.1 compiles it just fine producing the correct result. MSVC 8 blows
out on the 2nd use of Add<> complaining that "Add<> is not defined". As far
as I can tell it should be legal C++ code --- at least this is how I
interpret the standard.

If it's my misunderstanding, please explain. If it's a bug, I should file it
to MS as such.

Any help is appreciated.

Thank you in advance,

Eugene



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Gene Bushuyev
Guest





PostPosted: Thu Dec 15, 2005 10:48 am    Post subject: Re: vc8 bug? Reply with quote



"Eugene Lazutkin" <eugene_lazutkin (AT) hotmail (DOT) com> wrote

Quote:
I encountered a problem while switching from MSVC 7.1 to MSVC 8. I
was able to isolate it and reproduce it. Here it goes (obviously the real
code is not about arithmetics):

============================
#include <iostream
using namespace std;

template< int I = 0
struct Helper
{
enum { RESULT = I };
template< int J > struct Add : public Helper< RESULT + J > {};
};

int main()
{
typedef Helper
::Add<1
::Add<2
::Add<3
Result;
cout << Result::RESULT << endl;
return 0;
}
============================

MSVC 7.1 compiles it just fine producing the correct result. MSVC 8 blows
out on the 2nd use of Add<> complaining that "Add<> is not defined". As
far
as I can tell it should be legal C++ code --- at least this is how I
interpret the standard.

If it's my misunderstanding, please explain. If it's a bug, I should file
it
to MS as such.

It does look like a compiler bug. The standard requires implicit
instantiation of the Helper<> classes (14.7.1/1). It looks like VC8
instantiates only the first Helper<0> class and breaks after that.


-- Gene Bushuyev


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.