Bug 59052 - Partial specialization of template with dependent non-type template argument not correctly resolved
Summary: Partial specialization of template with dependent non-type template argument ...
Status: RESOLVED DUPLICATE of bug 59044
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-08 17:09 UTC by Tom De Caluwé
Modified: 2013-12-05 23:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
The preprocessed code (257 bytes, text/plain)
2013-11-08 17:09 UTC, Tom De Caluwé
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom De Caluwé 2013-11-08 17:09:03 UTC
Created attachment 31183 [details]
The preprocessed code

This bug seems to be related to bug 59044 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59044).

The following code when compiled with 'g++ spec.cpp' is rejected by gcc 4.8.1:

/* ---- spec.cpp ---------------------------------------- */
namespace N {

template <class T>
struct C {
    template <class U, T t>
    struct Implementation {};
};

template <class T>
template <T t>
struct C<T>::Implementation<void, t> {
    static void method() {}
};

}

int main() {
    N::C<int>::Implementation<void, 0>::method();
}
/* ---------------------------------------------------- */

The bug is only triggered when the second template argument is a non-type template argument dependent on the template argument of the enclosing class template. The error message produced by g++ 4.8.1 (as found in the g++-4.8 package in the Ubuntu 13.10 repo, see below for build information):

spec.cpp: In function ‘int main()’:
spec.cpp:18:5: error: ‘method’ is not a member of ‘N::C<int>::Implementation<void, 0>’
     N::C<int>::Implementation<void, 0>::method();
     ^

This bug is still present in the gcc-snapshot package. However the code compiles fine in g++ 4.7.3 (as found in the g++-4.7 package).

Additional information:

GCC version: gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8) 
System type: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Comment 1 Jason Merrill 2013-12-05 19:15:10 UTC
This is indeed the same issue as 59044.

*** This bug has been marked as a duplicate of bug 59044 ***
Comment 2 Jason Merrill 2013-12-05 22:46:38 UTC
Author: jason
Date: Thu Dec  5 22:46:36 2013
New Revision: 205720

URL: http://gcc.gnu.org/viewcvs?rev=205720&root=gcc&view=rev
Log:
	PR c++/59044
	PR c++/59052
	* pt.c (most_specialized_class): Use the partially instantiated
	template for deduction.  Drop the TMPL parameter.

Added:
    trunk/gcc/testsuite/g++.dg/template/partial14.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 3 Jason Merrill 2013-12-05 23:28:28 UTC
Author: jason
Date: Thu Dec  5 23:28:25 2013
New Revision: 205723

URL: http://gcc.gnu.org/viewcvs?rev=205723&root=gcc&view=rev
Log:
	PR c++/59044
	PR c++/59052
	* pt.c (most_specialized_class): Use the partially instantiated
	template for deduction.  Drop the TMPL parameter.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/template/partial14.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/pt.c