Bug 1960701 - Wrong-code regression starting with gcc 8.2
Summary: Wrong-code regression starting with gcc 8.2
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: ---
Assignee: Marek Polacek
QA Contact: Václav Kadlčík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-14 15:53 UTC by Jakub Jelinek
Modified: 2023-07-18 14:19 UTC (History)
6 users (show)

Fixed In Version: gcc-8.5.0-2.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:35:43 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2021:4386 0 None None None 2021-11-09 19:35:57 UTC

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


Note You need to log in before you can comment on or make changes to this bug.