[Bug c++/88092] New: class nontype template deduction failed when providing type to class
hanicka at hanicka dot net
gcc-bugzilla@gcc.gnu.org
Mon Nov 19 13:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092
Bug ID: 88092
Summary: class nontype template deduction failed when providing
type to class
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hanicka at hanicka dot net
Target Milestone: ---
Created attachment 45034
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45034&action=edit
minimal example (workaround is also part of the code)
I found that a type deduction placeholder in class nontype template parameter
is not resolved properly if given as template argument to a class.
GCC 9 HEAD (commit: 20f6624). Example attached with marked problem. Also found
workaround using function template with a class nontype template parameter.
--------
Using built-in specs.
COLLECT_GCC=g++-HEAD
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/lto-wrapper
Target: x86_64-apple-darwin18.2.0
Configured with: ../configure --build=x86_64-apple-darwin18.2.0
--prefix=/usr/local/Cellar/gcc/HEAD-20f6624
--libdir=/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-HEAD
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC
HEAD-20f6624' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--disable-nls --disable-multilib --with-native-system-header-dir=/usr/include
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
gcc version 9.0.0 20181118 (experimental) (Homebrew GCC HEAD-20f6624)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a'
'-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc'
'-mtune=core2'
/usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus
-E -quiet -v -D__DYNAMIC__ cnttp2.cpp -fPIC -mmacosx-version-min=10.14.0
-mtune=core2 -std=c++2a -fpch-preprocess -o cnttp2.ii
ignoring nonexistent directory
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory
"/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../x86_64-apple-darwin18.2.0/include"
ignoring nonexistent directory
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0
/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/x86_64-apple-darwin18.2.0
/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/../../../../../../include/c++/9.0.0/backward
/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include
/usr/local/Cellar/gcc/HEAD-20f6624/lib/gcc/HEAD/gcc/x86_64-apple-darwin18.2.0/9.0.0/include-fixed
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++2a'
'-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc'
'-mtune=core2'
/usr/local/Cellar/gcc/HEAD-20f6624/libexec/gcc/x86_64-apple-darwin18.2.0/9.0.0/cc1plus
-fpreprocessed cnttp2.ii -fPIC -quiet -dumpbase cnttp2.cpp
-mmacosx-version-min=10.14.0 -mtune=core2 -auxbase cnttp2 -std=c++2a -version
-o cnttp2.s
GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental)
(x86_64-apple-darwin18.2.0)
compiled by GNU C version 9.0.0 20181118 (experimental), GMP version
6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (Homebrew GCC HEAD-20f6624) version 9.0.0 20181118 (experimental)
(x86_64-apple-darwin18.2.0)
compiled by GNU C version 9.0.0 20181118 (experimental), GMP version
6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.20-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ac5ba3fc9d630765279df693b1849957
cnttp2.cpp: In function 'constexpr void test()':
cnttp2.cpp:20:19: error: class template argument deduction failed:
20 | using t3 = foo<fs>; // <- this fails
| ^
cnttp2.cpp:20:19: error: no matching function for call to
'fixed_string(fixed_string)'
cnttp2.cpp:7:42: note: candidate: 'template<class CharT, long unsigned int N>
fixed_string(const CharT (&)[N])-> fixed_string<CharT, N>'
7 | template <typename CharT, std::size_t N> fixed_string(const CharT
(&str)[N]) -> fixed_string<CharT, N>;
| ^~~~~~~~~~~~
cnttp2.cpp:7:42: note: template argument deduction/substitution failed:
cnttp2.cpp:20:19: note: mismatched types 'const CharT [N]' and 'fixed_string'
20 | using t3 = foo<fs>; // <- this fails
| ^
cnttp2.cpp:4:12: note: candidate: 'template<class CharT, long unsigned int N>
fixed_string(...)-> fixed_string<CharT, N>'
4 | constexpr fixed_string(...) { }
| ^~~~~~~~~~~~
cnttp2.cpp:4:12: note: template argument deduction/substitution failed:
cnttp2.cpp:20:19: note: couldn't deduce template parameter 'CharT'
20 | using t3 = foo<fs>; // <- this fails
| ^
cnttp2.cpp:3:49: note: candidate: 'template<class CharT, long unsigned int N>
fixed_string(fixed_string<CharT, N>)-> fixed_string<CharT, N>'
3 | template <typename CharT, std::size_t N> struct fixed_string {
| ^~~~~~~~~~~~
cnttp2.cpp:3:49: note: template argument deduction/substitution failed:
cnttp2.cpp:20:19: note: mismatched types 'fixed_string<CharT, N>' and
'fixed_string'
20 | using t3 = foo<fs>; // <- this fails
| ^
More information about the Gcc-bugs
mailing list