struct S { char x[2]; unsigned y; }; constexpr bool func(const S s) { return s.x[0] != 42 || s.x[1] != 0; } static_assert(!func({{42, 7}, 0}), "bla"); --- Compiled with -std=c++11 -O on various compilers (http://gcc.godbolt.org/) starting with 4.7.1 up to 7 I get an ICE: Example with 5.4: 12 : in constexpr expansion of 'func(S{char [2]{'*', '\007'}, 0u})' 12 : internal compiler error: in cxx_eval_bit_field_ref, at cp/constexpr.c:2090 static_assert(!func({{42, 7}, 0}), "bla");
Confirmed.
Created attachment 40165 [details] code that fails
Sorry - accidentally added test case attachment to this bug. The bug I reported is likely related https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78551
Likely related to PR57335.
*** Bug 83231 has been marked as a duplicate of this bug. ***
Fixed by r250659; will add the test.
Author: mpolacek Date: Sat Jun 8 00:17:13 2019 New Revision: 272068 URL: https://gcc.gnu.org/viewcvs?rev=272068&root=gcc&view=rev Log: PR c++/77771 * g++.dg/cpp0x/constexpr-77771.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-77771.C Modified: trunk/gcc/testsuite/ChangeLog
Fixed.