Bug 26957 - [4.0/4.1 regression] ICE in make_decl_rtl, at varasm.c:871
Summary: [4.0/4.1 regression] ICE in make_decl_rtl, at varasm.c:871
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.3
: P2 normal
Target Milestone: 4.0.4
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
: 29182 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-30 23:52 UTC by Randolph Chung
Modified: 2006-09-26 07:10 UTC (History)
7 users (show)

See Also:
Host: hppa-unknown-linux
Target: hppa-unknown-linux
Build: hppa-unknown-linux
Known to work: 3.3.6 3.4.5 4.2.0 4.1.2
Known to fail: 4.0.3 4.1.0
Last reconfirmed: 2006-09-08 15:51:50


Attachments
Testcase (125.52 KB, application/gzip)
2006-03-30 23:52 UTC, Randolph Chung
Details
Cut-down test case (106 bytes, text/plain)
2006-06-08 17:47 UTC, Steve Ellcey
Details
Proposed patch (318 bytes, patch)
2006-06-08 20:34 UTC, Steve Ellcey
Details | Diff
Patch to clear DECL_VALUE_EXPR (315 bytes, patch)
2006-09-07 19:09 UTC, Jason Merrill
Details | Diff
test case (248 bytes, application/octet-stream)
2006-09-25 22:03 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Randolph Chung 2006-03-30 23:52:34 UTC
$ g++ -c bug.cc
bug.cc: In member function 'void TAO_DynCommon::_ZTv0_n100_N13TAO_DynCommon17insert_longdoubleEN7ACE_CDR10LongDoubleE(CORBA::LongDouble)':
bug.cc:28887: internal compiler error: in make_decl_rtl, at varasm.c:871
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.

Testcase is extracted from the "ace" package on Debian.
Comment 1 Randolph Chung 2006-03-30 23:52:56 UTC
Created attachment 11171 [details]
Testcase
Comment 2 Andrew Pinski 2006-03-31 00:12:35 UTC
This works just fine on x86.
Comment 3 Falk Hueffner 2006-03-31 08:40:06 UTC
Confirmed, also present in 4.2.0 20060218

Test case:

struct LongDouble {
    char ld[16];
};

struct DynAny  {
    virtual void insert_longdouble(LongDouble value) = 0;
};

struct TAO_DynCommon : public virtual DynAny {
    virtual void insert_longdouble (LongDouble value);
};

void TAO_DynCommon::insert_longdouble (LongDouble value) { }
Comment 4 John David Anglin 2006-03-31 15:04:05 UTC
Breakpoint 1, make_decl_rtl (decl=0x40148880) at ../../gcc/gcc/varasm.c:968
968       gcc_assert (TREE_CODE (decl) != TYPE_DECL
(gdb) list
963                   || TREE_PUBLIC (decl)
964                   || DECL_EXTERNAL (decl)
965                   || DECL_REGISTER (decl));
966
967       /* And that we were not given a type or a label.  */
968       gcc_assert (TREE_CODE (decl) != TYPE_DECL
969                   && TREE_CODE (decl) != LABEL_DECL);
970
971       /* For a duplicate declaration, we can be called twice on the
972          same DECL node.  Don't discard the RTL already made.  */
(gdb) bt
#0  make_decl_rtl (decl=0x40148880) at ../../gcc/gcc/varasm.c:968
#1  0x003a6adc in init_one_libfunc (name=<value optimized out>)
    at ../../gcc/gcc/optabs.c:5131
#2  0x000f1768 in init_exception_processing () at ../../gcc/gcc/cp/except.c:80
#3  0x0003878c in cxx_init_decl_processing () at ../../gcc/gcc/cp/decl.c:3250
#4  0x000b3760 in cxx_init () at ../../gcc/gcc/cp/lex.c:386
#5  0x0041dad4 in toplev_main (argc=<value optimized out>,
    argv=<value optimized out>) at ../../gcc/gcc/toplev.c:1864
#6  0x403566d8 in __libc_start_main () from /lib/libc.so.6
#7  0x0001d190 in _start () at ../sysdeps/hppa/elf/start.S:84
(gdb) p debug_tree (decl)
 <function_decl 0x40148880 __gxx_personality_v0
    type <function_type 0x400db540
        type <integer_type 0x400d22a0 int public SI
            size <integer_cst 0x400c22b8 constant invariant 32>
            unit size <integer_cst 0x400c2048 constant invariant 4>
            align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x400c2270 -2147483648> max <integer_cst 0x400c2288 2147483647>
            pointer_to_this <pointer_type 0x400d2cc0>>
        SI size <integer_cst 0x400c22b8 32> unit size <integer_cst 0x400c2048 4>
        align 32 symtab 0 alias set -1>
    public external SI file <built-in> line 0>
$1 = void
Comment 5 dave 2006-03-31 15:34:06 UTC
Subject: Re:  [4.0/4.1/4.2 regression] ICE in make_decl_rtl, at varasm.c:871

> ------- Comment #4 from danglin at gcc dot gnu dot org  2006-03-31 15:04 -------
> Breakpoint 1, make_decl_rtl (decl=0x40148880) at ../../gcc/gcc/varasm.c:968
> 968       gcc_assert (TREE_CODE (decl) != TYPE_DECL
> (gdb) list
> 963                   || TREE_PUBLIC (decl)
> 964                   || DECL_EXTERNAL (decl)
> 965                   || DECL_REGISTER (decl));
> 966
> 967       /* And that we were not given a type or a label.  */
> 968       gcc_assert (TREE_CODE (decl) != TYPE_DECL
> 969                   && TREE_CODE (decl) != LABEL_DECL);
> 970
> 971       /* For a duplicate declaration, we can be called twice on the
> 972          same DECL node.  Don't discard the RTL already made.  */
> (gdb) bt
> #0  make_decl_rtl (decl=0x40148880) at ../../gcc/gcc/varasm.c:968
> #1  0x003a6adc in init_one_libfunc (name=<value optimized out>)
>     at ../../gcc/gcc/optabs.c:5131
> #2  0x000f1768 in init_exception_processing () at ../../gcc/gcc/cp/except.c:80
> #3  0x0003878c in cxx_init_decl_processing () at ../../gcc/gcc/cp/decl.c:3250
> #4  0x000b3760 in cxx_init () at ../../gcc/gcc/cp/lex.c:386
> #5  0x0041dad4 in toplev_main (argc=<value optimized out>,
>     argv=<value optimized out>) at ../../gcc/gcc/toplev.c:1864
> #6  0x403566d8 in __libc_start_main () from /lib/libc.so.6
> #7  0x0001d190 in _start () at ../sysdeps/hppa/elf/start.S:84
> (gdb) p debug_tree (decl)
>  <function_decl 0x40148880 __gxx_personality_v0
>     type <function_type 0x400db540
>         type <integer_type 0x400d22a0 int public SI
>             size <integer_cst 0x400c22b8 constant invariant 32>
>             unit size <integer_cst 0x400c2048 constant invariant 4>
>             align 32 symtab 0 alias set -1 precision 32 min <integer_cst
> 0x400c2270 -2147483648> max <integer_cst 0x400c2288 2147483647>
>             pointer_to_this <pointer_type 0x400d2cc0>>
>         SI size <integer_cst 0x400c22b8 32> unit size <integer_cst 0x400c2048
> 4>
>         align 32 symtab 0 alias set -1>
>     public external SI file <built-in> line 0>
> $1 = void

Oops, wrong call to ame_decl_rtl.  The one causing the ICE is:

Assembling functions:
 virtual void TAO_DynCommon::insert_longdouble(LongDouble) void TAO_DynCommon::_ZTv0_n12_N13TAO_DynCommon17insert_longdoubleE10LongDouble(LongDouble)
 Breakpoint 1, make_decl_rtl (decl=0x400cc4d0) at ../../gcc/gcc/varasm.c:957
 957       gcc_assert (TREE_CODE (decl) != PARM_DECL
 (gdb) bt
 #0  make_decl_rtl (decl=0x400cc4d0) at ../../gcc/gcc/varasm.c:957
 #1  0x00302dd4 in expand_expr_real_1 (exp=<value optimized out>,
     target=<value optimized out>, tmode=<value optimized out>,
     modifier=EXPAND_NORMAL, alt_rtl=0xc0013208) at ../../gcc/gcc/expr.c:6730
 #2  0x00308414 in expand_expr_real (exp=0x400cc4d0, target=0x40175460,
     tmode=BLKmode, modifier=EXPAND_NORMAL, alt_rtl=0xc0013208)
     at ../../gcc/gcc/expr.c:6576
 #3  0x0030dd6c in store_expr (exp=0x400cc4d0, target=0x40175460,
     call_param_p=0) at ../../gcc/gcc/expr.c:4275
 #4  0x002fb3a4 in expand_assignment (to=0x400cc9a0, from=0x400cc4d0)
     at ../../gcc/gcc/expr.c:4154
 #5  0x002ffa9c in expand_expr_real_1 (exp=<value optimized out>,
     target=<value optimized out>, tmode=<value optimized out>,
     modifier=<value optimized out>, alt_rtl=0x0) at ../../gcc/gcc/expr.c:8467
 #6  0x0030832c in expand_expr_real (exp=0x4014c550, target=0x40175460,
     tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0)
     at ../../gcc/gcc/expr.c:6570
 #7  0x00410f08 in expand_expr_stmt (exp=0x400cc4d0) at expr.h:494
 #8  0x00458d68 in expand_gimple_basic_block (bb=0x400cdf50)
     at ../../gcc/gcc/cfgexpand.c:1368
 #9  0x00459ec0 in tree_expand_cfg () at ../../gcc/gcc/cfgexpand.c:1627
 #10 0x00454e68 in execute_one_pass (pass=0x64ec90)
     at ../../gcc/gcc/passes.c:863
 #11 0x00455008 in execute_pass_list (pass=0x64ec90)
     at ../../gcc/gcc/passes.c:910
 #12 0x001a3750 in tree_rest_of_compilation (fndecl=0x40148700)
     at ../../gcc/gcc/tree-optimize.c:418
 #13 0x0010753c in expand_body (fn=0x40148700)
     at ../../gcc/gcc/cp/semantics.c:3012
 #14 0x000fc2f4 in use_thunk (thunk_fndecl=0x40175460,
     emit_p=<value optimized out>) at ../../gcc/gcc/cp/method.c:520
 #15 0x001074c4 in expand_body (fn=0x40172e00)
     at ../../gcc/gcc/cp/semantics.c:2965
 #16 0x00495cf0 in cgraph_expand_function (node=0x40172f00)
     at ../../gcc/gcc/cgraphunit.c:1102
 #17 0x00498994 in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1167
 #18 0x000a7390 in cp_finish_file () at ../../gcc/gcc/cp/decl2.c:3147
 #19 0x00172284 in c_common_parse_file (set_yydebug=<value optimized out>)
     at ../../gcc/gcc/c-opts.c:1165
 #20 0x0041dbdc in toplev_main (argc=<value optimized out>,
     argv=<value optimized out>) at ../../gcc/gcc/toplev.c:999
 #21 0x403566d8 in __libc_start_main () from /lib/libc.so.6
 #22 0x0001d190 in _start () at ../sysdeps/hppa/elf/start.S:84
(gdb) p debug_tree (decl)
 <var_decl 0x400cc4d0 value___0
    type <record_type 0x40177000 LongDouble type_1 type_5 BLK
	size <integer_cst 0x400c2528 constant invariant 128>
	unit size <integer_cst 0x400c2540 constant invariant 16>
	align 8 symtab 0 alias set -1
	fields <field_decl 0x40177120 ld type <array_type 0x401770c0>
	     nonlocal decl_3 BLK file TAO.cc line 2 size <integer_cst 0x400c2528 128> unit size <integer_cst 0x400c2540 16>
	     align 8 offset_align 64
	     offset <integer_cst 0x400c2060 constant invariant 0>
	     bit offset <integer_cst 0x400c27f8 constant invariant 0> context <record_type 0x40177000 LongDouble> chain <type_decl 0x4014a9c0 LongDouble>>
	 X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
	 pointer_to_this <pointer_type 0x40177ea0> chain <type_decl 0x4014a958 LongDouble>>
    used BLK file TAO.cc line 13 size <integer_cst 0x400c2528 128> unit size <integer_cst 0x400c2540 16>
    align 8 context <function_decl 0x40172e00 insert_longdouble>>
(gdb) step
951     {
(gdb)
957       gcc_assert (TREE_CODE (decl) != PARM_DECL
(gdb)
961       gcc_assert (TREE_CODE (decl) != VAR_DECL
(gdb)

TAO.cc:9: internal compiler error: in make_decl_rtl, at varasm.c:965

Dave
Comment 6 Steve Ellcey 2006-06-08 17:47:23 UTC
Created attachment 11639 [details]
Cut-down test case

Here is a cutdown test case that fails on hppa1.1-hp-hpux11.11.  It does not fail on hppa64-hp-hpux11.11 or ia64-hp-hpux11.23.  If you shrink the size of LDD then the problem goes away so it seems related to how we are passing large (>64 bits) structures.
Comment 7 Steve Ellcey 2006-06-08 20:34:07 UTC
Created attachment 11642 [details]
Proposed patch

I am going to test the attached patch and will submit it to gcc-patches if there are no regressions.
Comment 8 Steve Ellcey 2006-06-08 21:12:45 UTC
I do not think my patch is correct.  The variable causing the problem is created in gimplify_parameters by a call to create_tmp_var.  This local variable is only created on systems that pass structures by pointers and which are callee copied.

I think this variable should be a local stack variable but I think that is what we have now.  Then we run into the gcc_assert in make_decl_rtl, if I just comment out that assert I run into one in expand_expr_real_1.

It may be that the function context is not set when creating this temporary, that would explain the expand_expr_real_1 assert.
Comment 9 Thomas Girard 2006-07-24 07:23:58 UTC
For what it's worth:
 * I have been able to reproduce this problem on a cross compiler
 * the same code compiles without problem if inheritance is not virtual
Comment 10 Jason Merrill 2006-09-07 19:09:41 UTC
Created attachment 12205 [details]
Patch to clear DECL_VALUE_EXPR

This patch fixes the testcase in comment #3 with a cross compiler.  Could someone with hppa hardware give it a whirl?
Comment 11 Jason Merrill 2006-09-07 21:06:38 UTC
Subject: Bug 26957

Author: jason
Date: Thu Sep  7 21:06:28 2006
New Revision: 116760

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116760
Log:
        PR c++/26957
        * method.c (use_thunk): Clear DECL_HAS_VALUE_EXPR_P on copied
        parms.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/thunk6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/method.c

Comment 12 Jason Merrill 2006-09-07 21:23:05 UTC
waiting for feedback.
Comment 13 Randolph Chung 2006-09-08 15:04:47 UTC
Works for me on the original test case (ACE package) and on the reduced test case in #3. Tested on hppa-linux native.
Comment 14 Andrew Pinski 2006-09-08 15:51:50 UTC
Then fixed on the mainline, marking as such and changing back to new for the other branches.
Comment 15 Jason Merrill 2006-09-08 16:52:49 UTC
Subject: Bug 26957

Author: jason
Date: Fri Sep  8 16:52:40 2006
New Revision: 116781

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116781
Log:
        PR c++/26957
        * method.c (use_thunk): Clear DECL_HAS_VALUE_EXPR_P on copied
        parms.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/thunk6.C
      - copied unchanged from r116760, trunk/gcc/testsuite/g++.dg/inherit/thunk6.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/method.c

Comment 16 Jason Merrill 2006-09-08 16:54:06 UTC
Subject: Bug 26957

Author: jason
Date: Fri Sep  8 16:53:55 2006
New Revision: 116782

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116782
Log:
        PR c++/26957
        * method.c (use_thunk): Clear DECL_HAS_VALUE_EXPR_P on copied
        parms.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/thunk6.C
      - copied unchanged from r116760, trunk/gcc/testsuite/g++.dg/inherit/thunk6.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/method.c

Comment 17 Jason Merrill 2006-09-08 16:54:18 UTC
Applied to 4.0 and 4.1 as well.
Comment 18 Jason Merrill 2006-09-09 16:11:42 UTC
Subject: Bug 26957

Author: jason
Date: Sat Sep  9 16:11:34 2006
New Revision: 116799

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116799
Log:
        PR c++/26957
        * method.c (use_thunk): Fix patch for 4.0 branch.

Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/method.c

Comment 19 Andrew Pinski 2006-09-22 15:44:30 UTC
*** Bug 29182 has been marked as a duplicate of this bug. ***
Comment 20 Debian GCC Maintainers 2006-09-25 22:03:57 UTC
Created attachment 12326 [details]
test case

[forwarded from http://bugs.debian.org/388626]

testcase ICEs with 3.4.6, 4.0 CVS, 4.1 CVS and current trunk, works with 2.95.4 3.3.6
Comment 21 Debian GCC Maintainers 2006-09-25 22:05:25 UTC
bug should be reopened, or should a new report be filed?

  Matthias
Comment 22 Andrew Pinski 2006-09-26 07:10:04 UTC
*** Bug 29209 has been marked as a duplicate of this bug. ***