Bug 45959 - [4.6 Regression] ICE: tree code 'template_type_parm' is not supported in gimple streams with -flto/-fwhopr
Summary: [4.6 Regression] ICE: tree code 'template_type_parm' is not supported in gimp...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code, lto
: 45960 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-10 08:18 UTC by Zdenek Sojka
Modified: 2021-08-25 22:58 UTC (History)
4 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work: 4.5.1
Known to fail: 4.6.0
Last reconfirmed: 2010-10-10 11:29:26


Attachments
testcase (607 bytes, text/plain)
2010-10-10 08:18 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-10-10 08:18:33 UTC
Created attachment 22011 [details]
testcase

Compiler output:
$ gcc -flto testcase.C
testcase.C:106:1: internal compiler error: tree code 'template_type_parm' is not supported in gimple streams
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r165241 - crash
r165220 - crash
r165152 - OK
Comment 1 Richard Biener 2010-10-10 11:29:26 UTC
We are writing DECL_CONTEXT of a TYPE_DECL which is a RECORD_TYPE which
is not instantiated.

We should probably simply clear all fields of RECORD_TYPEs which are
"incomplete" this way.

A more radical approach would be to do for TYPE_FIELDS what we do now
for BLOCK_SUBBLOCKS and BLOCK_VARS - write them lazily (but given that
they are possibly shared between multiple instances of RECORD_TYPEs
re-constructing the field list isn't really possible).

I have a patch.
Comment 2 Richard Biener 2010-10-10 11:30:16 UTC
*** Bug 45960 has been marked as a duplicate of this bug. ***
Comment 3 Jason Merrill 2010-10-10 20:11:01 UTC
Mine.
Comment 4 Jason Merrill 2010-10-11 13:25:45 UTC
Author: jason
Date: Mon Oct 11 13:25:37 2010
New Revision: 165306

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165306
Log:
	PR lto/45959
	PR lto/45960
	* pt.c (tsubst_copy) [INTEGER_CST]: Instantiate the type.

Added:
    trunk/gcc/testsuite/g++.dg/lto/20101010-1_0.C
    trunk/gcc/testsuite/g++.dg/lto/20101010-2_0.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jason Merrill 2010-10-11 13:30:16 UTC
Fixed.
Comment 6 Ryan Johnson 2010-10-11 13:53:42 UTC
Actually, this isn't a regression -- not on 4.6, at least. The following minimal test case makes x86_64-unknown-linux-gnu-gcc-4.5.1 die with the same error message:

$ cat > lto-bug.h <<EOF
#pragma interface
template<class T> struct foo;
template<class T>
struct foo<T*&> : foo<T&> {
    foo<T*&>(T* t) : foo<T&>(*t) { }
};
EOF

$ cat > lto-bug.C <<EOF
#pragma implementation "lto-bug.h"
#include "lto-bug.h"
EOF

$ gcc-4.5.1 -flto lto-bug.C
In file included from lto-bug.C:2:0:
lto-bug.h:6:2: internal compiler error: tree code ‘template_type_parm’ is not supported in gimple streams
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Removing anything at all makes the ICE disappear

I don't have a copy of the 4.6 sources to test whether the just checked-in fix takes care of this... reopen?
Comment 7 Jason Merrill 2010-10-11 16:49:52 UTC
(In reply to comment #6)
> #pragma interface
> template<class T> struct foo;
> template<class T>
> struct foo<T*&> : foo<T&> {
>     foo<T*&>(T* t) : foo<T&>(*t) { }
> };

This looks like a different bug that just produces the same error message.  This testcase works fine with pre-4.6, and is not fixed in 4.5 by the patch for 45959.