https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100649
Bug ID: 100649 Summary: ICE in coerce_template_parms (releases) or cxx_eval_constant_expression (trunk) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ebotcazou at gcc dot gnu.org Target Milestone: --- The compiler ICEs either in coerce_template_parms for releases: t.cpp: In member function 'void B<T>::foo(const A<32>&)': t.cpp:12:24: internal compiler error: in coerce_template_parms, at cp/pt.c:9082 12 | A<2 + mesg.size()> local_mesg; | ^ 0x6267e6 coerce_template_parms /home/eric/cvs/gcc-11/gcc/cp/pt.c:9082 or in cxx_eval_constant_expression on the trunk: t.cpp: In member function 'void B<T>::foo(const A<32>&)': t.cpp:12:24: internal compiler error: in cxx_eval_constant_expression, at cp/constexpr.c:6622 12 | A<2 + mesg.size()> local_mesg; | ^ 0x651967 cxx_eval_constant_expression /home/eric/cvs/gcc/gcc/cp/constexpr.c:6622 for the following testcase: template <int N> struct A { constexpr int size () const { return N; } }; template <class T> struct B { void foo (const A<32> &mesg) { A<2 + mesg.size()> local_mesg; } }; The code is correctly rejected when the 2nd template declaration is removed: t.cpp: In member function 'void B::foo(const A<32>&)': t.cpp:12:24: error: 'mesg' is not a constant expression 12 | A<2 + mesg.size()> local_mesg; | ^ t.cpp:12:11: note: in template argument for type 'int' 12 | A<2 + mesg.size()> local_mesg; | ~~^~~~~~~~~~~~~