Bug 3033

Summary: The 'using typename' construct won't compile
Product: gcc Reporter: Seth LaForge <sethml>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gabriel.dos-reis, gcc-bugs, jadamcze, lerdsuwa, sethml
Priority: P3 Keywords: rejects-valid
Version: 3.0   
Target Milestone: ---   
Host: i386-pc-linux-gnu Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description Seth LaForge 2001-06-01 13:46:01 UTC
	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'
Comment 1 Seth LaForge 2001-06-01 13:46:01 UTC
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].
Comment 2 Seth LaForge 2001-06-01 18:22:49 UTC
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

Comment 3 gabriel.dos-reis 2001-06-02 02:58:27 UTC
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

Comment 4 gabriel.dos-reis 2001-06-02 03:44:10 UTC
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

Comment 5 jadamcze 2001-06-02 12:33:04 UTC
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
 
 
  
 
 
Comment 6 Kriang Lerdsuwanakij 2001-06-03 02:16:03 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.