C++ allows the word 'typename' after a 'using' directive. _The C++ Programming Language_ (third edition) [Stroustrup], section A.7 (Grammar/Declarations) defines the using directive: using-declaration: "using" "typename"(opt) "::"(opt) nested-name-specifier unqualified-id ";" Release: 3.0 20010526 (Debian prerelease) (Debian testing/unstable) Environment: System: Linux burn 2.2.18 #1 Thu Dec 14 09:22:25 PST 2000 i686 unknown Architecture: i686 host: i386-pc-linux-gnu build: i386-pc-linux-gnu target: i386-pc-linux-gnu configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux How-To-Repeat: Attempt to compile the following: struct C { typedef int INT; }; struct D : public C { using typename C::INT; }; int main() { D::INT x = 666; } The compiler complains: test.cc:6: parse error before `typename'
Fix: I'm not sure if there are cases in which the 'typename' portion is required. I've seen it in production code (the loki library, from _Modern C++ Design_ [Alexandrescu].
From: sethml@ofb.net To: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org Subject: Re: c++/3033: 'using typename' construct doesn't work Date: Fri, 01 Jun 2001 18:22:49 -0700 > sethml@ofb.net writes: > > | C++ allows the word 'typename' after a 'using' directive. _The C++ Pro > gramming Language_ (third edition) [Stroustrup], section A.7 (Grammar/Declara > tions) defines the using directive: > | using-declaration: > | "using" "typename"(opt) "::"(opt) nested-name-specifier > | unqualified-id ";" > > The C++ grammar is not context-free, you cannot deduce construct > validity just from pure grammar productions. OK, fine. The question remains: is this a legal construct, or not? Seth
From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> To: sethml@ofb.net Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org Subject: Re: c++/3033: 'using typename' construct doesn't work Date: 02 Jun 2001 02:58:27 +0200 sethml@ofb.net writes: | C++ allows the word 'typename' after a 'using' directive. _The C++ Programming Language_ (third edition) [Stroustrup], section A.7 (Grammar/Declarations) defines the using directive: | using-declaration: | "using" "typename"(opt) "::"(opt) nested-name-specifier | unqualified-id ";" The C++ grammar is not context-free, you cannot deduce construct validity just from pure grammar productions. -- Gaby
From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> To: sethml@ofb.net Cc: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>, gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org Subject: Re: c++/3033: 'using typename' construct doesn't work Date: 02 Jun 2001 03:44:10 +0200 sethml@ofb.net writes: | > sethml@ofb.net writes: | > | > | C++ allows the word 'typename' after a 'using' directive. _The C++ Pro | > gramming Language_ (third edition) [Stroustrup], section A.7 (Grammar/Declara | > tions) defines the using directive: | > | using-declaration: | > | "using" "typename"(opt) "::"(opt) nested-name-specifier | > | unqualified-id ";" | > | > The C++ grammar is not context-free, you cannot deduce construct | > validity just from pure grammar productions. | | OK, fine. The question remains: is this a legal construct, or not? The constructs you sent were all ill-formed. See 14.6/5 of the C++ definition text. -- Gaby
From: "Jonathan Adamczewski" <jadamcze@utas.edu.au> To: sethml@ofb.net Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org Subject: Re: c++/3033: 'using typename' construct doesn't work Date: Sat, 2 Jun 2001 12:33:04 +1000 (EST) > > | OK, fine. The question remains: is this a legal construct, or not? > > The constructs you sent were all ill-formed. See 14.6/5 of the C++ definition text. Or see C.13.5 in The C++ Programming Language 3rd Ed. (pp. 856-858) j. -- Put your leader at the back. This means there is less chance of his head being knocked off. -- Generale tips for Captive
State-Changed-From-To: open->closed State-Changed-Why: Not a bug.