Topic: Q: C++ WP Grammar Bug?


Author: bparker@gil.com.au (Brian Parker)
Date: 1997/05/25
Raw View
Norbert Berzen <norbert@dune.gia.rwth-aachen.de> wrote:
>...
>the CD2 WP draft states in 14.7.2 [temp.explicit] the following
>as a valid explicit template instantiation:
>  /*1*/     template<class T> class Array { /* ... */ };
>  /*2*/     template class Array<char>;
>and the grammar states the following:
>            explicit-instantiation:
>                     template declaration
>The problem arises when parsing the `explicit-instantiation'
>contained in line /*2*/ since - AFAIK - there is not any way to
>produce "class Array<char>" from the non-terminal `declaration'.
>One can produce "Array<char>" from `declaration', but there
>is no way to produce the `class-key' "class" which stands in
>front of "Array<char>".
>--
>Norbert [norbert@dune.gia.rwth-aachen.de  (134.130.159.38)]

I agree that there appears to be a flaw in the grammar here. More
generally, it seems that one cannot write the elaborated
class A<int> a;
instead of
A<int> a;
in a declaration.

I am not sure what 14.7.2 [temp.explicit] means when it refers to
"(un)qualified-id" as by my reading these terms apply to expressions,
not declarations.

My initial thoughts on a fix for this are to change the production for
"elaborated-type-specifier" to something like-

elaborated-type-specifier:
 class-key :: opt nested-name-specifier opt class-name
 enum :: opt nested-name-specifier opt enum name
 typename :: opt nested-name-specifier type-name

(the change to the typename alternative is an unrelated
simplification).

(Also, "template" in the explicit-instantiation production should be
in the typewriter font).

Anyone else have any thoughts on this?
Have I missed something here?

,Brian Parker (bparker@gil.com.au)
---
[ 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: Norbert Berzen <norbert@dune.gia.rwth-aachen.de>
Date: 1997/05/22
Raw View
Hello C++ experts,

the CD2 WP draft states in 14.7.2 [temp.explicit] the following
as a valid explicit template instantiation:

  /*1*/     template<class T> class Array { /* ... */ };
  /*2*/     template class Array<char>;


and the grammar states the following:

            explicit-instantiation:
                     template declaration


The problem arises when parsing the `explicit-instantiation'
contained in line /*2*/ since - AFAIK - there is not any way to
produce "class Array<char>" from the non-terminal `declaration'.
One can produce "Array<char>" from `declaration', but there
is no way to produce the `class-key' "class" which stands in
front of "Array<char>".

Could you help me, please!

Greetings
Norbert

P.S.

A similar problem arises in the context of explicit-specializations.

--
Norbert [norbert@dune.gia.rwth-aachen.de  (134.130.159.38)]

N. Berzen, Geod. Inst. der RWTH-Aachen, Templergraben 55, 52056 Aachen
---
[ 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                             ]