
Hello Alexander, Saturday, January 20, 2007, 12:22:35 AM, you wrote:
I commited the fix for 1358600 - lexical_cast & pure virtual functions & VC 8 STL (http://tinyurl.com/yvowz6) for VC++ only but later I found that Intel 8.1 and Comeau online don't compile as well.
The problem appears in numeric_limits functions. In this usecase, they return an abstract class by value. Although lexical_cast never uses those functions, it seems that some compilers do more strick checking than I thought they should.
For example,
class A { public: virtual void foo() = 0; };
template<class T> struct limits { static int const value = true; static T declared_only(); };
int main() { limits<A>::value; }
fails to compile on VC++ 8, Intel 8.1 and Comeau online at the point of the declared_only declaration.
However, if I replace a body of A with a declaration (class A;), those compilers don't complain anymore. What is this, a compiler bug or my misunderstanding? I remember that some freedom compiling template code is allowed (and therefore, some compiler compiles while some others don't) but I don't know where to search in the standard.
According to 14.7.1 (namely 14.7.1/2 and 14.7.1/3) the declared_only member should not be instantiated unless it is used somewhere in the code. So I see no reason a compiler to want T to be not abstract. Looks like compiler bug to me. -- Best regards, Andrey mailto:andysem@mail.ru