Bug 84805 - [8 Regression] ICE in get_odr_type, at ipa-devirt.c:2096 since r258133
Summary: [8 Regression] ICE in get_odr_type, at ipa-devirt.c:2096 since r258133
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 8.0.1
: P1 normal
Target Milestone: 8.0
Assignee: Eric Botcazou
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-03-10 12:02 UTC by Martin Liška
Modified: 2018-04-18 20:05 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.3.0
Known to fail: 8.0
Last reconfirmed: 2018-03-10 00:00:00


Attachments
test-case (1.28 KB, text/plain)
2018-03-10 12:02 UTC, Martin Liška
Details
test-case (155 bytes, text/plain)
2018-03-10 12:02 UTC, Martin Liška
Details
test-case (1.07 KB, text/plain)
2018-03-10 12:02 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2018-03-10 12:02:02 UTC
Following ICEs:

$ g++ -shared -fPIC -flto=8 -O2 -std=gnu++17 libre-1.ii libre-2.ii libre-3.ii
libre-1.ii:139:7: warning: type ‘struct XclRoot’ violates the C++ One Definition Rule [-Wodr]
 class XclRoot {
       ^
libre-2.ii:1:7: note: a different type is defined in another translation unit
 class XclRoot {
       ^
libre-1.ii:142:16: note: the first difference of corresponding definitions is field ‘mrData’
   XclRootData &mrData;
                ^
libre-2.ii:1:7: note: a type with different number of fields is defined in another translation unit
 class XclRoot {
       ^
libre-1.ii:144:7: warning: type ‘struct XclImpRoot’ violates the C++ One Definition Rule [-Wodr]
 class XclImpRoot : XclRoot {};
       ^
libre-2.ii:5:7: note: a type with different bases is defined in another translation unit
 class XclImpRoot : XclRoot {};
       ^
libre-2.ii:6:8: warning: type ‘struct RootData’ violates the C++ One Definition Rule [-Wodr]
 struct RootData {
        ^
libre-3.ii:121:8: note: a different type is defined in another translation unit
 struct RootData {
        ^
libre-2.ii:7:14: note: the first difference of corresponding definitions is field ‘pIR’
   XclImpRoot pIR;
              ^
libre-3.ii:122:11: note: a field with different name is defined in another translation unit
   BiffTyp eDateiTyp;
           ^
libre-3.ii:18:7: warning: type ‘struct __shared_ptr’ violates the C++ One Definition Rule [-Wodr]
 class __shared_ptr : __shared_ptr_access< a, l > {
       ^
libre-1.ii:21:7: note: a different type is defined in another translation unit
 class __shared_ptr : __shared_ptr_access< _Tp, _Lp > {
       ^
libre-3.ii:20:6: note: the first difference of corresponding definitions is field ‘_M_ptr’
   m *_M_ptr;
      ^
libre-1.ii:23:17: note: a field of same name but different type is defined in another translation unit
   element_type *_M_ptr;
                 ^
libre-3.ii:19:14: note: type ‘struct m’ should match type ‘struct element_type’
   using m = a;
              ^
libre-1.ii:22:27: note: the incompatible type is defined here
   using element_type = _Tp;
                           ^
libre-1.ii:103:8: warning: type ‘struct XclRootData’ violates the C++ One Definition Rule [-Wodr]
 struct XclRootData {
        ^
libre-3.ii:82:8: note: a different type is defined in another translation unit
 struct XclRootData {
        ^
libre-1.ii:136:15: note: the first difference of corresponding definitions is field ‘mxRD’
   RootDataRef mxRD;
               ^
libre-3.ii:107:22: note: a field of same name but different type is defined in another translation unit
   std::n< RootData > mxRD;
                      ^
libre-1.ii:111:39: note: type ‘struct RootDataRef’ should match type ‘struct n’
   typedef std::shared_ptr< RootData > RootDataRef;
                                       ^
libre-3.ii:23:31: note: the incompatible type is defined here
 template < typename a > class n : __shared_ptr< a > {};
                               ^
lto1: internal compiler error: in get_odr_type, at ipa-devirt.c:2096
0x8d7ca7 get_odr_type(tree_node*, bool)
        ../../gcc/ipa-devirt.c:2096
0x8d7e0c register_odr_type(tree_node*)
        ../../gcc/ipa-devirt.c:2121
0x6156a0 lto_read_decls
        ../../gcc/lto/lto.c:1782
0x6178c4 lto_file_finalize
        ../../gcc/lto/lto.c:2076
0x6178c4 lto_create_files_from_ids
        ../../gcc/lto/lto.c:2086
0x6178c4 lto_file_read
        ../../gcc/lto/lto.c:2127
0x6178c4 read_cgraph_and_symbols
        ../../gcc/lto/lto.c:2839
0x6178c4 lto_main()
        ../../gcc/lto/lto.c:3356
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make: *** [/tmp/cc6NqUBv.mk:2: /tmp/ccU4uBCo.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Comment 1 Martin Liška 2018-03-10 12:02:18 UTC
Created attachment 43614 [details]
test-case
Comment 2 Martin Liška 2018-03-10 12:02:29 UTC
Created attachment 43615 [details]
test-case
Comment 3 Martin Liška 2018-03-10 12:02:47 UTC
Created attachment 43616 [details]
test-case
Comment 4 Eric Botcazou 2018-03-12 09:15:32 UTC
This looks an ICE on invalid code though since the ODR is violated.
Comment 5 Eric Botcazou 2018-03-12 09:46:33 UTC
Investigating.
Comment 6 Eric Botcazou 2018-03-12 12:12:55 UTC
We have an ordering issue because of forward declarations:

class XclImpRoot : XclRoot {};
class XclImpColRowSettings : XclImpRoot {};

register_odr_type called on XclImpRoot causes get_odr_type to assign the id number to XclImpColRowSettings before XclImpRoot because the base class:

class XclRoot {
public:
  virtual ~XclRoot();
  XclRootData &mrData;
};

has an XclRootData field which ultimately references:

struct RootData {
  BiffTyp eDateiTyp;
  ExtSheetBuffer *pExtSheetBuff;
  SharedFormulaBuffer *pShrfmlaBuff;
  ExtNameBuff *pExtNameBuff;
  ExcelToSc *pFmlaConverter;
  XclImpColRowSettings *pColRowBuff;
};

which contains a pointer to XclImpColRowSettings.
Comment 7 Eric Botcazou 2018-03-13 10:05:23 UTC
Author: ebotcazou
Date: Tue Mar 13 10:04:51 2018
New Revision: 258481

URL: https://gcc.gnu.org/viewcvs?rev=258481&root=gcc&view=rev
Log:
	PR lto/84805
	* ipa-devirt.c (odr_subtypes_equivalent_p): Do not get the ODR type of
	incomplete types.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-devirt.c
Comment 8 Eric Botcazou 2018-03-13 10:06:55 UTC
Thanks for the reduced testcase.
Comment 9 Martin Liška 2018-03-13 13:04:59 UTC
(In reply to Eric Botcazou from comment #8)
> Thanks for the reduced testcase.

I thank you for the fast fix. I can confirm that libreoffice now builds fine.
Are you considering adding the reduced test-case to our test-suite?
Comment 10 Eric Botcazou 2018-03-13 16:54:11 UTC
> I thank you for the fast fix. I can confirm that libreoffice now builds fine.

You're welcome.

> Are you considering adding the reduced test-case to our test-suite?

See the submission.
Comment 11 Martin Liška 2018-04-18 20:05:41 UTC
Author: marxin
Date: Wed Apr 18 20:05:10 2018
New Revision: 259477

URL: https://gcc.gnu.org/viewcvs?rev=259477&root=gcc&view=rev
Log:
Revert r25841.

2018-04-18  Martin Liska  <mliska@suse.cz>

	Revert
	2018-03-13  Eric Botcazou  <ebotcazou@adacore.com>

	PR lto/84805
	* ipa-devirt.c (odr_subtypes_equivalent_p): Do not get the ODR type of
	incomplete types.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-devirt.c