Bug 1217267 - internal compiler error: in fold_convert_loc, at fold-const.c:1922
Summary: internal compiler error: in fold_convert_loc, at fold-const.c:1922
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: gcc
Version: 7.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: Miroslav Franc
URL:
Whiteboard:
: 1222631 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-29 22:34 UTC by Robert Thornthwaite
Modified: 2016-02-01 02:30 UTC (History)
4 users (show)

Fixed In Version: gcc-4.8.5-1.el7
Doc Type: Bug Fix
Doc Text:
Previously, GCC could generate wrong code from code that passed a union data type with a signed and an unsigned integer between two functions as a parameter. The compiler could incorrectly insert the __builtin_unreachable call into a codepath in the program that was, in fact, reachable, which resulted in a crash. This bug in the IPA inline analysis has been fixed, and GCC now generates correct code also in the described scenario.
Clone Of:
Environment:
Last Closed: 2015-11-19 12:22:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Preprocessed source (4.46 MB, text/x-csrc)
2015-04-29 22:34 UTC, Robert Thornthwaite
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2080 0 normal SHIPPED_LIVE gcc bug fix and enhancement update 2015-11-19 10:51:58 UTC

Description Robert Thornthwaite 2015-04-29 22:34:27 UTC
Created attachment 1020351 [details]
Preprocessed source

Description of problem:
  I got this error while trying to compile.

Version-Release number of selected component (if applicable):
  gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) 


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Marek Polacek 2015-04-30 09:25:25 UTC
Reproduced with vanilla 4.8; 4.9 is fine.  Bisecting...

Comment 3 Jakub Jelinek 2015-04-30 09:32:35 UTC
http://gcc.gnu.org/r218205

Comment 4 Jakub Jelinek 2015-04-30 09:37:17 UTC
And that commit had a follow-up:
http://gcc.gnu.org/r218316

Comment 5 Marek Polacek 2015-04-30 10:38:22 UTC
Reduced.  Only -O is needed to show the ICE.

class A
{
    int _M_p;
};
template < typename _Key, typename _Tp > class B
{
public:
    _Tp operator[](_Key);
};

union U
{
    long double ld;
    void *v;
};
A a;
void
fn1 (U p1)
{
    if (p1.v)
      *reinterpret_cast < A * >(p1.v) = a;
}

class C
{
public:
    C (A)
    {
        m_data.ld = 0;
        fn1 (m_data);
    }
    U m_data;
};

class D
{
public:
    A a1;
    A a2;
    void m_fn1 ()
    {
        arr[2][a1] = a2;
    } B < int, B < A, C > >arr;
};

void
fn2 ()
{
    D b;
    b.m_fn1 ();
}

Comment 6 Jakub Jelinek 2015-04-30 11:14:01 UTC
Slightly more cleaned up:

// { dg-options "-O -Wno-psabi" }
// { dg-do compile }

struct A { int a; };
template <typename T, typename V> struct B { V operator[] (T); };
union U { long double ld; void *v; };
A a;

void
bar (U &x)
{
  if (x.v) *reinterpret_cast <A *>(x.v) = a;
}

struct C { C (A) { c.ld = 0; bar (c); } U c; };
struct D { A d, e; void foo () { f[0][d] = e; } B <int, B <A, C> > f; };

void
baz ()
{
  D d;
  d.foo ();
}

Comment 7 Marek Polacek 2015-04-30 18:44:11 UTC
I've backported the relevant fixes to the 4.8 branch.

Comment 8 Robert Thornthwaite 2015-04-30 19:19:34 UTC
(In reply to Marek Polacek from comment #7)
> I've backported the relevant fixes to the 4.8 branch.

You guys are awesome!    Thank you.    Will this be out in a patch to the compiler sometime soon?

Comment 9 Jakub Jelinek 2015-04-30 19:20:57 UTC
Most likely in RHEL 7.2.

Comment 10 Marek Polacek 2015-05-18 16:47:01 UTC
*** Bug 1222631 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2015-11-19 12:22:45 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, 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://rhn.redhat.com/errata/RHBA-2015-2080.html


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