https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109168
Bug ID: 109168 Summary: bogus error: 'X' is not a valid template argument of type 'Y' because 'X' is not a variable Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: waffl3x at protonmail dot com Target Milestone: --- https://godbolt.org/z/5xxPhhno7 struct stores_fptr { void (*fptr)(); }; void func() {} struct holds_value { static constexpr auto value = stores_fptr{&func}; }; template<stores_fptr V> struct takes_value {}; using go = takes_value<holds_value::value>; There are a few workarounds for this that I could find, the most obvious being the following changes (working example): https://godbolt.org/z/81xr36bYc template<auto V> struct takes_value {}; inline constexpr auto f = holds_value::value.fptr; using go = takes_value<f>; I want to note, the bug is still present in the broken example if `takes_value` takes a deduced (auto) non type template parameter, I explicitly state the type just to reduce the example further. The first (broken) snippit works in clang, and is broken in gcc trunk, gcc 12.2, and gcc 11.2, I was not able to test on MSVC. I'm mildly concerned that this is one of those cases where clang is wrong to accept the code, but I was able to find enough workarounds that I feel like I'm not incorrect. The code also fails on my system with version: g++ (GCC) 13.0.1 20230219 (experimental) Here is the gcc version on compiler explorer at the time of writing: g++ (Compiler-Explorer-Build-gcc-0c061da91a3657afdb3fac68e4595af685909a1a-binutils-2.38) 13.0.1 20230316 (experimental) BTW, should I be selecting the oldest version that a bug occurs or the newest version? I observed the behavior all the way back to 10.1, which appears to be when support for C++20 starts. I guess the better question to ask is how do I assign multiple versions?