https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
Bug ID: 105110 Summary: NTTP type deduction fails when dependent of previous NTTPs Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: j.galecki11 at gmail dot com Target Milestone: --- Consider the following minimal example: ``` template <int> struct S {}; template <auto> struct V {}; template <int I, S<I> s> void foo(V<s>) {} void bar() { constexpr S<1> s; foo(V<s>{}); } ``` CE link for the reader's convenience: https://godbolt.org/z/1cYK9s1Ta GCC fails to compile this (consistent across versions), complaining about cv-qualifier mismatch, which seems wholly irrelevant. Clang compiles without warnings. The problem is that when instantiating a function parametrized with a NTTP, GCC fails to deduce the type of the NTTP parameter based on the other function parameters. This causes problems with passing around constexpr values, as shown in the following second example: https://godbolt.org/z/3Tnjx1Wxb (again, Clang compiles and executes as intended). As I cannot quite figure out whether the standard requires the deduction described above to be possible, I see 2 possibilities: 1) This is simply a bug in GCC. 2) GCC is correct in refusing to compile the provided examples (Clang is wrong). In this case, the emitted error should probably better describe the problem.