As mentioned in https://gcc.gnu.org/PR95226 , gcc 8.2 regressed from 8.1 on the #include <vector> struct T { unsigned a; float b {8.}; }; int main() { T t = {1}; std::vector<T> tt = {{1}, {2}}; if (t.a != 1 || t.b != 8.0f || tt[0].a != 1 || tt[0].b != 8.0f || tt[1].a != 2 || tt[1].b != 8.0f) __builtin_abort (); } testcase (even without optimizations).
This worked fine in gcc <= 7.x, 8.1 and works fine in 9.1 and later too.
I've investigated this a bit. The wrong-code started with https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=bdc2c1ea35c16d3bbd3711430d8035dd54cfcf20 which is a different change than what was committed to (then) trunk: https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=5603790dbf233c31c60d8877f632c06c4753acfb I think we should back out the first (fcl_c99) change, add the test in #c0, and then 1) remove array-temp1.C, or 2) apply the second (TREE_READONLY) patch and keep array-temp1.C. I think trading a wrong-code fix for a missed-optimization fix is a good deal. I've tested both 1) and 2). Jason/Jakub, any preference? 2) seems to be in the current trunk still, so is probably fairly safe.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Low: gcc security and bug fix update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2021:4386