https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88355
Bug ID: 88355 Summary: [c++20] Placeholder non-type template argument type deduction fails with custom types Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: emmanuel.le-tr...@cnrs-orleans.fr Target Milestone: --- Deducing the type of a non-type template parameter containing a placeholder fails with custom types. $ g++-9 -v Using built-in specs. COLLECT_GCC=g++-9 COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9 --program-suffix=-9 : (reconfigured) ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9 --program-suffix=-9 Thread model: posix gcc version 9.0.0 20181127 (experimental) (GCC) $ cat bug_2.cpp #include <type_traits> // for std::is_same_v struct T {}; template <auto value> struct U {}; template <auto value> void f (U <value>) {} int main () { constexpr T t; f (U<1>{}); // OK f<t> (U<t>{}); // OK // This works: auto x = t; static_assert (std::is_same_v <decltype (x), T>); // OK // This should work as well, as per [temp.arg.nontype], see below f (U<t>{}); // Error } $ g++-9 -std=c++2a -Wall -Wextra bug_2.cpp -o bug_2 bug_2.cpp: In function ‘int main()’: bug_2.cpp:20:21: error: no matching function for call to ‘f(U<T()>)’ 20 | f (U<t>{}); // Error | ^ bug_2.cpp:9:10: note: candidate: ‘template<auto value> void f(U<value>)’ 9 | void f (U <value>) {} | ^ bug_2.cpp:9:10: note: template argument deduction/substitution failed: bug_2.cpp:20:21: note: mismatched types ‘T’ and ‘const T’ 20 | f (U<t>{}); // Error | ^ make: *** [<builtin>: bug_2] Error 1 The standardese in the latest draft is: ---8<--- 12.3.2 Template non-type arguments [temp.arg.nontype] If the type T of a template-parameter (12.1) contains a placeholder type (9.1.7.5) or a placeholder for a deduced class type (9.1.7.6), the type of the parameter is the type deduced for the variable x in the invented declaration T x = template-argument ; --->8---