Topic: Template issue in MS VC++ 4.0, Non Standard?
Author: jason@cygnus.com (Jason Merrill)
Date: 1996/03/19 Raw View
>>>>> Peter J Brock <peter@magna.com.au> writes:
> The following code illustrates a bug in the implementation of
> templates in MS Visual C++ 4.0.
Yup, looks that way.
[snip]
> So leads one to the question of how will compilers be vetted against a
> standard when it comes?
With testsuites, same as with any other language. There are already
several commercial C++ testsuite vendors.
Jason
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: peter@magna.com.au (Peter J Brock)
Date: 1996/03/18 Raw View
The following code illustrates a bug in the implementation of
templates in MS Visual C++ 4.0.
//___________begin code sample__________________________
// test.cpp
template <class T>
class VeryTesting
{
public:
VeryTesting();
T& operator()();
T m_T;
};
template <class T>
inline
VeryTesting<T>::VeryTesting ()
{
}
template <class T>
inline T&
VeryTesting<T>::operator ()()
{
return m_T;
}
// Uncomment this block of code and it all works!
// template VeryTesting<double>;
class A
{
public :
A(){}
~A(){}
VeryTesting<double>& test(VeryTesting<double>& fdTest)
{
fdTest() = 5.0; //error C2064: term does not evaluate to a function
return fdTest;
}
};
main()
{
VeryTesting<double> f;
f() = 5.0;
A aObject;
aObject.test(f);
}
//___________end code sample___________________________
The problem is that VeryTesting<double> is not instantiated correctly
by the MS Visual C++ 4.0 compiler. This results in the error message
that says function fdTest() does not evaluate to a function.
The code compiles under Borland 4.5.
So leads one to the question of how will compilers be vetted against a
standard when it comes?
Cheers,
Peter J Brock http://www.magna.com.au/~peter
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]