Bug 1960701

Summary: Wrong-code regression starting with gcc 8.2
Product: Red Hat Enterprise Linux 8 Reporter: Jakub Jelinek <jakub>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: Václav Kadlčík <vkadlcik>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, fweimer, jakub, jason, ohudlick, vkadlcik
Version: 8.6Keywords: Bugfix, Triaged
Target Milestone: beta   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-8.5.0-2.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:35:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jakub Jelinek 2021-05-14 15:53:06 UTC
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).

Comment 1 Jakub Jelinek 2021-05-14 15:54:22 UTC
This worked fine in gcc <= 7.x, 8.1 and works fine in 9.1 and later too.

Comment 2 Marek Polacek 2021-05-27 21:05:26 UTC
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.

Comment 7 errata-xmlrpc 2021-11-09 19:35:43 UTC
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