https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93425

            Bug ID: 93425
           Summary: Template parameter deduction failure when template
                    parameters have template template parameter
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andysem at mail dot ru
  Target Milestone: ---

The following code fails to compile:

template< typename T >
struct plus {};

template< typename Q >
struct test
{
    template< template< typename > class BinaryFunT, typename NumberT >
    static void test_impl(NumberT n)
    {
    }

    static void test_arith()
    {
        test_impl< plus >(10);
    }
};


$ g++ -O3 -c -o test.o test.cpp 
test.cpp: In static member function ‘static void test<Q>::test_arith()’:
test.cpp:14:29: error: no matching function for call to
‘test<Q>::test_impl<plus>(int)’
   14 |         test_impl< plus >(10);
      |                             ^
test.cpp:8:17: note: candidate: ‘template<class Q>
template<template<template<class> class BinaryFunT, class NumberT>
template<class Q> template<class> class BinaryFunT, class NumberT> static void
test<Q>::test_impl(NumberT)’
    8 |     static void test_impl(NumberT n)
      |                 ^~~~~~~~~
test.cpp:8:17: note:   template argument deduction/substitution failed:
test.cpp:14:29: note:   mismatched types ‘NumberT’ and ‘int’
   14 |         test_impl< plus >(10);
      |                             ^

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-9ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)

The same code compiles fine with gcc 8.3.0 and clang 9. Compilation succeeds if
I remove the template template parameter from test_impl definition and
invokation.

Note also how gcc 9 messes up the template parameters lists in the error
message. If this is an unrelated problem, let me know if I should file a
separate bug to fix this.

Reply via email to