[Bug c++/68998] [5 Regression] Wrong code generated regarding constexpr arrays
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 21 10:30:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68998
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Testcase usable for testsuite:
template <typename T, int N>
struct A { T v[N]; };
constexpr A <int, 2>
foo ()
{
A <int, 2> a {};
a.v[1] = 1;
a.v[0] = 1;
return a;
}
constexpr A <int, 2> a = foo ();
int
main ()
{
int k = 0;
for (int i = 0; i < 2; i++)
for (int j = 0; j < a.v[i]; j++)
k++;
if (k != 2)
__builtin_abort ();
}
This got fixed on the trunk with r226949.
I'm surprised by the regression marker, as this seems to be broken since
r217663 when C++14 constexpr support has been added (before that it has been
rejected).
That said, it is a wrong-code bug, so maybe the r226949 change is backportable.
Jason?
More information about the Gcc-bugs
mailing list