https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94068
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Reduced testcase with -std=c++17 or -std=c++2a: enum class A { A1, A2 }; A foo (); long foo (int); template <typename> void bar () { const auto c{foo ()}; }