public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter
@ 2012-10-29 20:15 gccbugs at qo dot cx
  2012-10-29 20:18 ` [Bug c++/55127] " gccbugs at qo dot cx
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gccbugs at qo dot cx @ 2012-10-29 20:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

             Bug #: 55127
           Summary: [4.8 regression] Incorrect "dependent scope" error
                    with partial specialisation of non-type parameter
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gccbugs@qo.cx


The current GCC snapshot in Debian unstable seems to reject valid code (mininal
test case attached).

In a template function context, accessing a nested type of a template
instantiation of an unrelated(!) template class may be flagged as requiring a
'typename' for being a dependent scope.

AFAICS, it only happens in case of the instantiated template being partially
specialised for a non-type template parameter, like bool here:

struct some_class
{
  static const bool     is_valid_type = true;
};

template< typename Type
        , bool Valid = Type::is_valid_type >
struct wrapper;

template< typename Type >
struct wrapper< Type, true > { ... };

template< typename T >
int fun()
{
  wrapper< some_class >::type x; // fails w/ 4.8.0
}

$ g++-snapshot -c  -o typename-bug.o typename-bug.cpp

typename-bug.cpp: In function 'void fun()':
typename-bug.cpp:29:3: error: need 'typename' before
'wrapper<some_class>::type' because 'wrapper<some_class>' is a dependent scope
   wrapper<some_class>::type x;
   ^
typename-bug.cpp:29:29: error: expected ';' before 'x'
   wrapper<some_class>::type x;
                             ^
typename-bug.cpp: In instantiation of 'void fun() [with T = int]':
typename-bug.cpp:34:12:   required from here
typename-bug.cpp:29:3: error: dependent-name 'wrapper<some_class>::type' is
parsed as a non-type, but instantiation yields a type
   wrapper<some_class>::type x;
   ^
typename-bug.cpp:29:3: note: say 'typename wrapper<some_class>::type' if a type
is meant

A possible workaround is to partially specialise via a type parameter (as shown
in the attached file with WORKAROUND being defined).

The failing GCC version reports:

Using built-in specs.
COLLECT_GCC=g++-snapshot
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/i486-linux-gnu/4.8.0/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20121008-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id
--with-system-zlib --disable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-snap
--with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic
--disable-werror --enable-checking=yes --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.8.0 20121008 (experimental) [trunk revision 192192] (Debian
20121008-1) 

Code is accepted by all "other" GCC variants in Debian testing/unstable:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.7-3'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran --prefix=/usr --program-suffix=-4.4
--enable-shared --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-targets=all
--with-arch-32=i586 --with-tune=generic --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.7 (Debian 4.4.7-3) 

Using built-in specs.
COLLECT_GCC=g++-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.6/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-12'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586
--with-tune=generic --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-12) 

Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586
--with-tune=generic --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-4)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
@ 2012-10-29 20:18 ` gccbugs at qo dot cx
  2012-11-25 15:55 ` [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gccbugs at qo dot cx @ 2012-10-29 20:18 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

--- Comment #1 from Philipp A. Hartmann <gccbugs at qo dot cx> 2012-10-29 20:17:32 UTC ---
Created attachment 28565
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28565
minimal test-case (and workaround)

Without WORKAROUND being defined, GCC 4.8 fails with the mentioned error
message.  Otherwise with WORKAROUD defined all tested versions accept the code.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
  2012-10-29 20:18 ` [Bug c++/55127] " gccbugs at qo dot cx
@ 2012-11-25 15:55 ` rguenth at gcc dot gnu.org
  2012-12-06 15:33 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-11-25 15:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
  2012-10-29 20:18 ` [Bug c++/55127] " gccbugs at qo dot cx
  2012-11-25 15:55 ` [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization " rguenth at gcc dot gnu.org
@ 2012-12-06 15:33 ` paolo.carlini at oracle dot com
  2012-12-07 10:18 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-06 15:33 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-06
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-06 15:32:52 UTC ---
Confirmed.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (2 preceding siblings ...)
  2012-12-06 15:33 ` paolo.carlini at oracle dot com
@ 2012-12-07 10:18 ` paolo.carlini at oracle dot com
  2012-12-07 13:27 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-07 10:18 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-07 10:18:00 UTC ---
HJ, can we figure out when we started rejecting this?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (3 preceding siblings ...)
  2012-12-07 10:18 ` paolo.carlini at oracle dot com
@ 2012-12-07 13:27 ` rguenth at gcc dot gnu.org
  2012-12-07 13:28 ` hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-07 13:27 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
           Priority|P3                          |P1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (4 preceding siblings ...)
  2012-12-07 13:27 ` rguenth at gcc dot gnu.org
@ 2012-12-07 13:28 ` hjl.tools at gmail dot com
  2012-12-07 14:30 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hjl.tools at gmail dot com @ 2012-12-07 13:28 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2012-12-07 13:27:59 UTC ---
It is caused by revision 190830:

http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00808.html


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (5 preceding siblings ...)
  2012-12-07 13:28 ` hjl.tools at gmail dot com
@ 2012-12-07 14:30 ` paolo.carlini at oracle dot com
  2012-12-07 19:30 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-07 14:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |jason at gcc dot gnu.org

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-07 14:30:09 UTC ---
Thanks!


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (6 preceding siblings ...)
  2012-12-07 14:30 ` paolo.carlini at oracle dot com
@ 2012-12-07 19:30 ` jason at gcc dot gnu.org
  2012-12-08  3:32 ` jason at gcc dot gnu.org
  2012-12-08  3:33 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-07 19:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (7 preceding siblings ...)
  2012-12-07 19:30 ` jason at gcc dot gnu.org
@ 2012-12-08  3:32 ` jason at gcc dot gnu.org
  2012-12-08  3:33 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-08  3:32 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-08 03:31:43 UTC ---
Author: jason
Date: Sat Dec  8 03:31:37 2012
New Revision: 194318

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194318
Log:
    PR c++/55127
    * search.c (accessible_in_template_p): New.
    * cp-tree.h: Declare it.
    * pt.c (instantiation_dependent_scope_ref_p): New.
    (value_dependent_expression_p): Use it.
    (instantiation_dependent_r): Likewise.
    * semantics.c (finish_decltype_type): Handle SCOPE_REF.

Added:
    trunk/gcc/testsuite/g++.dg/template/defarg16.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/cp/semantics.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization of non-type parameter
  2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
                   ` (8 preceding siblings ...)
  2012-12-08  3:32 ` jason at gcc dot gnu.org
@ 2012-12-08  3:33 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2012-12-08  3:33 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2012-12-08 03:33:21 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-12-08  3:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-29 20:15 [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter gccbugs at qo dot cx
2012-10-29 20:18 ` [Bug c++/55127] " gccbugs at qo dot cx
2012-11-25 15:55 ` [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization " rguenth at gcc dot gnu.org
2012-12-06 15:33 ` paolo.carlini at oracle dot com
2012-12-07 10:18 ` paolo.carlini at oracle dot com
2012-12-07 13:27 ` rguenth at gcc dot gnu.org
2012-12-07 13:28 ` hjl.tools at gmail dot com
2012-12-07 14:30 ` paolo.carlini at oracle dot com
2012-12-07 19:30 ` jason at gcc dot gnu.org
2012-12-08  3:32 ` jason at gcc dot gnu.org
2012-12-08  3:33 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).