https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92211
Neven Sajko <nsajko at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nsajko at gmail dot com --- Comment #1 from Neven Sajko <nsajko at gmail dot com> --- I'm hitting what seems like it may be the same bug on GCC 11.1.0. Self contained minimal or nearly minimal reproducer below. Works fine with Clang. GCC reports no error, but the code is miscompiled (returns 3 instead of 11). Additionally, ubsan reports: "t.cc:15:6: runtime error: execution reached the end of a value-returning function without returning a value". Additionally, GCC gives this bogus warning during compilation: "t.cc:15:12: warning: parameter ‘m’ set but not used [-Wunused-but-set-parameter]". namespace { template<typename Func> auto f(int m) -> long { int a{2}; return Func{}(a) - m; } template<int n> using Fun = decltype([](int a) -> int { return a * n; }); template<int n> auto g(int m) -> long { return f<Fun<n>>(m); } } // namespace auto main() -> int { int m{3}; return g<7>(m); }