 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eugene Lazutkin Guest
|
Posted: Tue Dec 13, 2005 11:26 pm Post subject: vc8 bug? |
|
|
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
|
Posted: Thu Dec 15, 2005 10:48 am Post subject: Re: vc8 bug? |
|
|
"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 |
|
 |
|
|
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
|
|