Topic: Implicit instantiation and the semantic analysis of definitions of
Author: scott douglass <sdouglass@arm.com>
Date: Thu, 20 Sep 2001 12:31:05 GMT Raw View
Michael Kochetkov wrote:
>=20
> Let us consider the following code:
> [Example:
> template <class T>
> class A {
> public:
> void f();
> };
>=20
> template <class T>
> void A<T>::f() {
> 0 =3D 1; // AAAA
> sdfg(); // BBBB
> T::a =3D 0; // CCCC
> }
> template <class T>
> void g() {
> 0 =3D 1; // DDDD
> sdfg(); // EEEE
> T::a =3D 0; // FFFF
> }
>=20
> int
> main()
> {
> A<int> a;
> }
> -- end example]
>=20
> Having studied 14.7.1 I have come to a conclusion that the example abov=
e
> shall be well-formed. But Comeau C++ since 4.2.44 begins to treat AAAA,
> BBBB, DDDD and EEEE as errors (all the other compilers I have access to
> treat the example above as well-formed).
>=20
> The question is: does the Standard admits the semantic analysis of
> _definitions_ of parameterized functions or member functions which will
> never be instantiated? (I believe that all the marked lines above are
> syntactically correct.)
14.6/7 says:
If no valid specialization can be generated for a template definition, an=
d that
template is not instantiated, the template definition is ill-formed, no
diagnostic required. [Note: if a template is instantiated, errors will be
diag=ADnosed according to the other rules in this Standard. Exactly when =
these
errors are diagnosed is a quality of implementation issue. ]
It then gives an example.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]