Summary: | [8 Regression] internal compiler error: in record_reference, at cgraphbuild.c:64 | ||
---|---|---|---|
Product: | gcc | Reporter: | Mykhailo Kremniov <officesamurai> |
Component: | c++ | Assignee: | Jason Merrill <jason> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | dimhen, hubicka, jason, webrown.cpp |
Priority: | P2 | Keywords: | ice-on-valid-code |
Version: | 8.2.0 | ||
Target Milestone: | 8.4 | ||
Host: | Target: | ||
Build: | Known to work: | 6.3.0 | |
Known to fail: | 8.1.0, 8.2.1 | Last reconfirmed: | 2018-10-08 00:00:00 |
Attachments: | Preprocessed source |
Description
Mykhailo Kremniov
2018-10-08 14:03:21 UTC
Created attachment 44808 [details]
Preprocessed source
Confirmed. GCC 7 doesn't like the preprocessed source so no idea if a regression. FYI: 6.3.0 is able to compile the non-preprocessed source. As for 7.x - 7.3.0 and earlier versions can't compile it due to another bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85470) and I don't have 7.4 at hand. I'm reducing that ... Reduced test-case: $ cat pr87554.ii template < class a > class b { static void c(a); static a &create() { c(instance); return mya; } static a mya; public: static a d() { create(); return a(); } static a &instance; }; template < class a > a &b< a >::instance = create(); class e; class f { public: void operator()(int g) { h(g); } template < class a > void h(a i) { p(j, i); } e *j; }; class e : public f { public: e(int); }; struct k { int l; }; template < class m, class a > void p(m, a) { b< k >::d(); } extern template class b< k >; int n; int o; void test() { e out(o); out(n); } Started with r259571. With first bad revision the constructor looks as follows: $ (gdb) p print_generic_expr(stderr, decl->decl_common.initial, 0) instance = b<k>::create ()$1 = void (gdb) p debug_tree(decl->decl_common.initial) <init_expr 0x7ffff6cc0a50 type <reference_type 0x7ffff6cbe540 type <record_type 0x7ffff6cb5f18 k type_5 type_6 SI size <integer_cst 0x7ffff6b730c0 constant 32> unit-size <integer_cst 0x7ffff6b730d8 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff6cb5f18 fields <function_decl 0x7ffff6cc8700 __ct > context <translation_unit_decl 0x7ffff6b60168 /home/marxin/Programming/testcases/pr87554.ii> full-name "struct k" X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown pointer_to_this <pointer_type 0x7ffff6cbe9d8> reference_to_this <reference_type 0x7ffff6cbe540> chain <type_decl 0x7ffff6c7bda8 k>> unsigned DI size <integer_cst 0x7ffff6b53e70 constant 64> unit-size <integer_cst 0x7ffff6b53e88 constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff6cbe540> side-effects arg:0 <var_decl 0x7ffff6cbd2d0 instance type <reference_type 0x7ffff6cbe540> readonly used public static tree_1 tree_3 unsigned external nonlocal read decl_3 decl_5 DI /home/marxin/Programming/testcases/pr87554.ii:11:25 size <integer_cst 0x7ffff6b53e70 64> unit-size <integer_cst 0x7ffff6b53e88 8> align:64 warn_if_not_align:0 context <record_type 0x7ffff6cbe348 b> initial <init_expr 0x7ffff6cc0a50> template-info 0x7ffff6ca6f20 chain <type_decl 0x7ffff6cbf1c8 b type <record_type 0x7ffff6cbe3f0 b> external nonlocal suppress-debug decl_4 VOID /home/marxin/Programming/testcases/pr87554.ii:1:30 align:8 warn_if_not_align:0 context <record_type 0x7ffff6cbe348 b> result <record_type 0x7ffff6cbe348 b> >> arg:1 <call_expr 0x7ffff6cca090 type <reference_type 0x7ffff6cbe540> side-effects fn <addr_expr 0x7ffff6cc2e40 type <pointer_type 0x7ffff6cc47e0> constant arg:0 <function_decl 0x7ffff6cc1000 create>> /home/marxin/Programming/testcases/pr87554.ii:11:50 start: /home/marxin/Programming/testcases/pr87554.ii:11:44 finish: /home/marxin/Programming/testcases/pr87554.ii:11:51>> before that C++ FE reported following error: $ ./xgcc -B. ~/Programming/testcases/pr87554.ii -c -O2 /home/marxin/Programming/testcases/pr87554.ii: In instantiation of ‘k& b<k>::instance’: /home/marxin/Programming/testcases/pr87554.ii:3:26: required from ‘static a& b<a>::create() [with a = k]’ /home/marxin/Programming/testcases/pr87554.ii:8:24: required from ‘static a b<a>::d() [with a = k]’ /home/marxin/Programming/testcases/pr87554.ii:26:55: required from ‘void p(m, a) [with m = e*; a = int]’ /home/marxin/Programming/testcases/pr87554.ii:16:39: required from ‘void f::h(a) [with a = int]’ /home/marxin/Programming/testcases/pr87554.ii:15:31: required from here /home/marxin/Programming/testcases/pr87554.ii:11:50: error: call to non-‘constexpr’ function ‘static a& b<a>::create() [with a = k]’ template < class a > a &b< a >::instance = create(); ~~~~~~^~ Jason can you please take a look? GCC 8.3 has been released. The constructor indeed looks broken to me: it should not have naked var_decl. So I am changing component to C++ Author: jason Date: Thu Apr 18 16:50:10 2019 New Revision: 270445 URL: https://gcc.gnu.org/viewcvs?rev=270445&root=gcc&view=rev Log: PR c++/87554 - ICE with extern template and reference member. The removed code ended up setting DECL_INITIAL to the INIT_EXPR returned by split_nonconstant_init, which makes no sense. This code was added back in 1996, so any rationale is long lost. * decl.c (cp_finish_decl): Don't set DECL_INITIAL of external vars. Added: trunk/gcc/testsuite/g++.dg/cpp0x/extern_template-5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c (In reply to Jan Hubicka from comment #8) > The constructor indeed looks broken to me: it should not have naked > var_decl. So I am changing component to C++ I agree that the C++ front end is wrong here, but I also wonder why cgraph is looking at the DECL_INITIAL of a DECL_EXTERNAL variable. > > The constructor indeed looks broken to me: it should not have naked > > var_decl. So I am changing component to C++ > > I agree that the C++ front end is wrong here, but I also wonder why cgraph is > looking at the DECL_INITIAL of a DECL_EXTERNAL variable. Well, at least for constant variables those are useful for contant folding. But I suppose we may take care to get rid of decl initials of non-readonly externals somewhere soon (we do it eventually as part of unreachable code removal) Honza > > -- > You are receiving this mail because: > You are on the CC list for the bug. The releases/gcc-8 branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:a57528b33be33d4428ac62901d04cf39807d624e commit r8-10074-ga57528b33be33d4428ac62901d04cf39807d624e Author: Jason Merrill <jason@redhat.com> Date: Tue Feb 25 13:37:18 2020 -0500 PR c++/87554 - ICE with extern template and reference member. The removed code ended up setting DECL_INITIAL to the INIT_EXPR returned by split_nonconstant_init, which makes no sense. This code was added back in 1996, so any rationale is long lost. gcc/cp/ChangeLog 2020-02-25 Jason Merrill <jason@redhat.com> PR c++/87554 - ICE with extern template and reference member. * decl.c (cp_finish_decl): Don't set DECL_INITIAL of external vars. Fixed for 8.4. |