The following causes an internal compiler error on gcc 9.2.0 on x86-64. I do not have access to other versions myself but tested on godbolt: It seems to say that 9.1, 9.2 and current trunk are affected, while 8.3 is unaffected. $ cat test.cpp constexpr bool f(const char*) { return true; } template<typename T> const char c = "FOO"[f("BAR") ? 1 : 0]; $ g++ test.cpp test.cpp:2:59: internal compiler error: in fold_convert_loc, at fold-const.c:2429 2 | template<typename T> const char c = "FOO"[f("BAR") ? 1 : 0]; | ^ The current code is obviously meaningless because it has been slowly scaled down from production code. I have noted that any of the following changes make the issue disappear : - removing the argument to f() - removing the templatization - removing the ternary operator
Confirmed.
Started with r267272. Will take a look.
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00819.html
Author: mpolacek Date: Sun Sep 15 20:22:27 2019 New Revision: 275736 URL: https://gcc.gnu.org/viewcvs?rev=275736&root=gcc&view=rev Log: PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF. * pt.c (build_non_dependent_expr): Call build_non_dependent_expr for the first operand. * g++.dg/cpp1y/var-templ63.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1y/var-templ63.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk so far.
Author: mpolacek Date: Tue Oct 8 13:38:35 2019 New Revision: 276699 URL: https://gcc.gnu.org/viewcvs?rev=276699&root=gcc&view=rev Log: PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF. * pt.c (build_non_dependent_expr): Call build_non_dependent_expr for the first operand. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp1y/var-templ63.C Modified: branches/gcc-9-branch/gcc/cp/ChangeLog branches/gcc-9-branch/gcc/cp/pt.c
Fixed.