J
Jens Mander
The following code generates errors when compiled using VC++ 7.1. However,
gcc 3.2.2 and comeau online have no problems with it. Is this illegal code
or a compiler bug? If it is the latter; was it fixed in the latest release
of VC++? Are there any workarounds for my version?
Thank you in advance!
====================
template <typename T>
struct Outer
{
template <T value = 0>
struct Inner {};
};
int main ()
{
Outer<int>::Inner<> fail;
}
====================
cl test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
test.cpp
test.cpp(10) : error C2976: 'Outer<T>::Inner' : too few template arguments
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2955: 'Outer<T>::Inner' : use of class template
requires t
emplate argument list
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2955: 'Outer<T>::Inner' : use of class template
requires t
emplate argument list
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2133: 'fail' : unknown size
test.cpp(10) : error C2512: 'Outer<T>::Inner' : no appropriate default
construct
or available
with
[
T=int
]
test.cpp(10) : error C2262: 'fail' : cannot be destroyed
gcc 3.2.2 and comeau online have no problems with it. Is this illegal code
or a compiler bug? If it is the latter; was it fixed in the latest release
of VC++? Are there any workarounds for my version?
Thank you in advance!
====================
template <typename T>
struct Outer
{
template <T value = 0>
struct Inner {};
};
int main ()
{
Outer<int>::Inner<> fail;
}
====================
cl test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
test.cpp
test.cpp(10) : error C2976: 'Outer<T>::Inner' : too few template arguments
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2955: 'Outer<T>::Inner' : use of class template
requires t
emplate argument list
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2955: 'Outer<T>::Inner' : use of class template
requires t
emplate argument list
with
[
T=int
]
test.cpp(5) : see declaration of 'Outer<T>::Inner'
with
[
T=int
]
test.cpp(10) : error C2133: 'fail' : unknown size
test.cpp(10) : error C2512: 'Outer<T>::Inner' : no appropriate default
construct
or available
with
[
T=int
]
test.cpp(10) : error C2262: 'fail' : cannot be destroyed