Bug 9634 - [DR224] Injected class name as qualifier should not make the name dependent
Summary: [DR224] Injected class name as qualifier should not make the name dependent
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 4.3.4
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 11118 12834 15863 19737 21783 (view as bug list)
Depends on:
Blocks: 12834 15179 27787 29469 29607
  Show dependency treegraph
 
Reported: 2003-02-09 03:16 UTC by poschmid
Modified: 2009-11-08 04:07 UTC (History)
14 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-03-04 18:21:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description poschmid 2003-02-09 03:16:01 UTC
g++ 3.4 does not accept the code taken from traits/isclasst.hpp from

Release:
3.4 20030204 (experimental)

Environment:
System: Linux linux 2.4.19-4GB #1 Wed Nov 27 00:56:40 UTC 2002 i686 unknown
Architecture: i686
SuSE 8.1
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-threads=posix --enable-languages=c,c++,f77,objc --enable-__cxa_atexit --disable-nls

How-To-Repeat:
source code t.C

template<typename T>
class IsFunctionT {
  private:
    typedef char One;
    typedef struct { char a[2]; } Two;
    template<typename U> static One test(...);
    template<typename U> static Two test(U (*)[1]);
  public:
    enum { Yes = sizeof(IsFunctionT<T>::test<T>(0)) == 1 };
    enum { No = !Yes };
};
compiling t.C

gcc 3.4
g++ -v t.C -W -Wall
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --enable-threads=posix --enable-languages=c,c++,f77,objc --enable-__cxa_atexit --disable-nls
Thread model: posix
gcc version 3.4 20030204 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE t.C -D__GNUG__=3 -quiet -dumpbase t.C -auxbase t -W -Wall -version -o /tmp/ccSkY98I.s
GNU C++ version 3.4 20030204 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.4 20030204 (experimental).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/c++/3.4
 /usr/local/include/c++/3.4/i686-pc-linux-gnu
 /usr/local/include/c++/3.4/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/include
 /usr/include
End of search list.
t.C:9: error: expected primary-expression
t.C:2: warning: all member functions in class `IsFunctionT<T>' are private

gcc 3.2
/usr/bin/g++ -v t.C -W -Wall
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i486-suse-linux
Thread model: posix
gcc version 3.2
 /usr/lib/gcc-lib/i486-suse-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i486__ t.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase t.C -W -Wall -version -o /tmp/cctz9rQi.s
GNU CPP version 3.2 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2 (i486-suse-linux)
	compiled by GNU C version 3.2.
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/include/g++/i486-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/i486-suse-linux/3.2/include
 /usr/i486-suse-linux/include
 /usr/include
End of search list.
t.C:2: warning: all member functions in class `IsFunctionT<T>' are private
 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/as -V -Qy -o /tmp/ccfqXMMs.o /tmp/cctz9rQi.s
GNU assembler version 2.12.90.0.15 (i486-suse-linux) using BFD version 2.12.90.0.15 20020717 (SuSE)
 /usr/lib/gcc-lib/i486-suse-linux/3.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i486-suse-linux/3.2/crtbegin.o -L/usr/lib/gcc-lib/i486-suse-linux/3.2 -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/lib -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../.. /tmp/ccfqXMMs.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i486-suse-linux/3.2/crtend.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crtn.o
/usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crt1.o: In function `_start':
/usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

Unformatted:
 >the book C++ templates by Vandevoorde and Josuttis. gcc 3.2 accepts
 >this code. I believe this a regression.
Comment 1 pcarlini 2003-02-09 09:56:30 UTC
From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  gcc-bugs@gcc.gnu.org,  nobody@gcc.gnu.org, 
 gcc-prs@gcc.gnu.org,  poschmid@lbl.gov
Cc:  
Subject: Re: c++/9634: Problems with templates (SFINAE)
Date: Sun, 09 Feb 2003 09:56:30 +0100

 First blush seems "obvious" that a template keyword is
 needed:
 
 9c9
 <     enum { Yes = sizeof(IsFunctionT<T>::test<T>(0)) == 1 };
 ---
  >     enum { Yes = sizeof(IsFunctionT<T>::template test<T>(0)) == 1 };
 
 however, some front-ends (e.g., EDG) accept it also without...
 
 Paolo.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9634
 
Comment 2 Paolo Carlini 2003-02-09 23:45:36 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: In the meanwhile I have asked Daveed Vandevoorde, who 
    replied, about the 'template' keyword:
    "I believe it has been clarified that it is not actually
    compulsory in this case because the qualifier is the
    injected class name.  However, this was the object of
    a post-1998 defect report against the standard."
Comment 3 Giovanni Bajo 2003-05-01 15:59:01 UTC
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<poschmid@lbl.gov>
Cc:  
Subject: Re: c++/9634: [3.4 regression] Problems with templates (SFINAE)
Date: Thu, 1 May 2003 15:59:01 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9634
 
 Yes, this is DR224
 (http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#224), which is
 in WP status (so the resolution will be adopted in the next version of the
 standard). Basically, this PR can be sumed up in the following code:
 
 --------------------------------------
 template <typename T>
 struct A
 {
     typedef int Bar;
 
     template <typename>
     struct N {};
 
     typedef Bar          type1;
     typedef A::Bar       type2;
     typedef A<T>::Bar    type3;
 
     typedef N<int>       type4;
     typedef A::N<int>    type5;
     typedef A<T>::N<int> type6;
 };
 --------------------------------------
 pr9634.cpp:10: error: ISO C++ forbids declaration of `Bar' with no type
 pr9634.cpp:10: error: expected `;'
 pr9634.cpp:11: error: ISO C++ forbids declaration of `Bar' with no type
 pr9634.cpp:11: error: expected `;'
 pr9634.cpp:14: error: `N<int>' specified as declarator-id
 pr9634.cpp:14: error: expected `;'
 pr9634.cpp:15: error: `N<int>' specified as declarator-id
 pr9634.cpp:15: error: expected `;'
 
 The code is legal and should be accepted by GCC. It's rejected from 3.4
 (which first disables the implicit typename/template extensions).
 
 NOTE for the fixer: I suggest to prepare a testcase using the official
 examples present in the above link, which tests all the conditions for both
 success and failure.
 
 Giovanni Bajo
Comment 4 Giovanni Bajo 2003-06-09 11:28:43 UTC
*** Bug 11118 has been marked as a duplicate of this bug. ***
Comment 5 Giovanni Bajo 2003-12-18 15:58:45 UTC
Will be posting a patch soon...
Comment 6 Giovanni Bajo 2003-12-19 18:32:57 UTC
Proposed patch is here: http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01722.html
Comment 7 Andrew Pinski 2004-01-01 05:41:51 UTC
*** Bug 12834 has been marked as a duplicate of this bug. ***
Comment 8 Steven Bosscher 2004-01-11 23:13:39 UTC
Giovanni, what happened to the patch? Time to ping, or was it pinged and 
rejected somewhere? 
 
Comment 9 Giovanni Bajo 2004-01-11 23:24:21 UTC
Subject: Re:  [3.4 regression] [DR224] Injected class name as qualifier should not make the name dependent

steven at gcc dot gnu dot org wrote:

> Giovanni, what happened to the patch? Time to ping, or was it pinged and
> rejected somewhere?

It was discussed here (see the followups):
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00490.html. There are two
outcomes:

1) My patch should be modified, removing its last hunk (the third). It was just
a hack and it turned out to be not needed. So I'll have to retest it.
2) Gaby said that the whole DR224 looked strange to him and would ask
clarifications to other members of the C++ committee.

So, I remove the "patch" keyword (since it's no more valid), and mark the bug
as suspended. After a few months, we can ping Gaby if we get no further
comments.

Giovanni Bajo


Comment 10 Giovanni Bajo 2004-01-11 23:24:54 UTC
Waiting for Gaby's discussion with the committee.
Comment 11 Andrew Pinski 2004-01-14 03:53:24 UTC
Moving to 3.5 as this is suspended waiting for the standards committe and most likely will 
not be fixed for 3.4.
Comment 12 Andrew Pinski 2004-06-07 23:09:05 UTC
*** Bug 15863 has been marked as a duplicate of this bug. ***
Comment 13 Gwenole Beauchesne 2004-06-07 23:27:55 UTC
Hi Gaby, do you have any news about it?
Comment 14 Andrew Pinski 2004-10-19 12:57:16 UTC
Removing the target milestone because the DR is questionable.
Comment 15 Andrew Pinski 2004-11-04 22:55:14 UTC
*** Bug 18304 has been marked as a duplicate of this bug. ***
Comment 16 Andrew Pinski 2005-02-01 04:43:54 UTC
*** Bug 19737 has been marked as a duplicate of this bug. ***
Comment 17 Andrew Pinski 2006-10-14 18:29:01 UTC
GDR,
  Any news from the committee on this issue?  It has been more than 2 years since the orginal message about talking to the committee.
Comment 18 Ian Lance Taylor 2007-04-25 06:45:55 UTC
Lowering priority of suspended PR.
Comment 19 Jason Merrill 2009-03-03 21:15:01 UTC
Unsuspending, no complains about DR 224 have come to the attention of the committee.
Comment 20 Jason Merrill 2009-03-04 18:42:41 UTC
Subject: Bug 9634

Author: jason
Date: Wed Mar  4 18:42:17 2009
New Revision: 144618

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144618
Log:
        PR c++/9634
        PR c++/29469
        PR c++/29607
        * decl.c (make_typename_type): Do look inside currently open classes.
        * parser.c (cp_parser_lookup_name): Likewise.
        (cp_parser_template_name): Likewise.
        * pt.c (dependent_scope_p): New function.
        * cp-tree.h: Declare it.
        * class.c (currently_open_class): Return fast if T isn't a class.

Added:
    trunk/gcc/testsuite/g++.dg/template/dependent-name5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 21 Jason Merrill 2009-03-04 19:38:03 UTC
Subject: Bug 9634

Author: jason
Date: Wed Mar  4 19:37:43 2009
New Revision: 144621

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144621
Log:
        PR c++/9634
        PR c++/29469
        PR c++/29607
        Implement DR 224.
        * decl.c (make_typename_type): Do look inside currently open classes.
        * parser.c (cp_parser_lookup_name): Likewise.
        (cp_parser_template_name): Likewise.
        * pt.c (dependent_scope_p): New function.
        * cp-tree.h: Declare it.
        * class.c (currently_open_class): Return fast if T isn't a class.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/dependent-name5.C
      - copied unchanged from r144618, trunk/gcc/testsuite/g++.dg/template/dependent-name5.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/class.c
    branches/gcc-4_3-branch/gcc/cp/cp-tree.h
    branches/gcc-4_3-branch/gcc/cp/decl.c
    branches/gcc-4_3-branch/gcc/cp/parser.c
    branches/gcc-4_3-branch/gcc/cp/pt.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 22 Jason Merrill 2009-03-04 19:41:59 UTC
Fixed for 4.3 and 4.4, not applying to 4.2.
Comment 23 Jason Merrill 2009-04-03 17:32:04 UTC
Subject: Bug 9634

Author: jason
Date: Fri Apr  3 17:31:38 2009
New Revision: 145510

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145510
Log:
Revert:
        PR c++/9634
        PR c++/29469
        PR c++/29607
        Implement DR 224.
        * decl.c (make_typename_type): Do look inside currently open classes.
        * parser.c (cp_parser_lookup_name): Likewise.
        (cp_parser_template_name): Likewise.
        * pt.c (dependent_scope_p): New function.
        * cp-tree.h: Declare it.
        * class.c (currently_open_class): Return fast if T isn't a class.

Removed:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/dependent-name5.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/class.c
    branches/gcc-4_3-branch/gcc/cp/cp-tree.h
    branches/gcc-4_3-branch/gcc/cp/decl.c
    branches/gcc-4_3-branch/gcc/cp/parser.c
    branches/gcc-4_3-branch/gcc/cp/pt.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 24 Jason Merrill 2009-11-08 04:07:15 UTC
*** Bug 21783 has been marked as a duplicate of this bug. ***