This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Possible bug in gcc/expr.c - expand_expr_real_1()?


Hi,

ICE was found when a large project was compiled with gcc 4.6.3(with
optimization enabled). It is working fine with gcc 4.5.3.

>From the stack trace it looked like a simple bug so I fix it and with
the following patch gcc-4.6.3 works fine. However I am not sure
whether this patch is correct or I am just suppressing the root cause
by this fix.
Can some gcc guru look at this and confirm whether it is a really a bug?

diff -rupN gcc-4.6.3/gcc/expr.c gcc-4.6.3.new1/gcc/expr.c
--- gcc-4.6.3/gcc/expr.c        2012-02-09 09:28:22.000000000 -0800
+++ gcc-4.6.3.new1/gcc/expr.c   2012-06-20 22:53:10.613748645 -0700
@@ -9182,6 +9182,7 @@ expand_expr_real_1 (tree exp, rtx target
        orig_op0 = op0
          = expand_expr (tem,
                         (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
+              && TYPE_SIZE (TREE_TYPE (tem))
                          && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
                              != INTEGER_CST)
                          && modifier != EXPAND_STACK_PARM

Regarding the ICE - I am trying to get a simple program to reproduce
it but no success so far(meaning gcc-4.6.3 compiles the simple program
without any problem).
So couldnt report it through bugzilla. Will report it once I have the repro.

Here is the stack trace that during the ICE.

(gdb) set follow-fork-mode child
(gdb) bt
#0  0x000000000062c67d in expand_expr_real_1 (exp=0x7ffff5521700,
target=0x0, tmode=VOIDmode, modifier=EXPAND_MEMORY, alt_rtl=0x0) at
../../gcc-4.6.3/gcc/expr.c:9185
#1  0x0000000000626e2a in expand_expr_real (exp=0x7ffff5521700,
target=0x0, tmode=VOIDmode, modifier=EXPAND_MEMORY, alt_rtl=0x0) at
../../gcc-4.6.3/gcc/expr.c:7383
#2  0x00000000008149c7 in expand_expr (exp=0x7ffff5521700, target=0x0,
mode=VOIDmode, modifier=EXPAND_MEMORY) at
../../gcc-4.6.3/gcc/expr.h:424
#3  0x0000000000816755 in expand_asm_operands (string=0x7ffff552a5a0,
outputs=0x7ffff550ad48, inputs=0x7ffff550ad20,
clobbers=0x7ffff552a640, labels=0x0, vol=1,
    locus=2953961) at ../../gcc-4.6.3/gcc/stmt.c:898
#4  0x000000000081752b in expand_asm_stmt (stmt=0x7ffff5a82c00) at
../../gcc-4.6.3/gcc/stmt.c:1187
#5  0x0000000000565880 in expand_gimple_stmt_1 (stmt=0x7ffff5a82c00)
at ../../gcc-4.6.3/gcc/cfgexpand.c:1922
#6  0x0000000000565d51 in expand_gimple_stmt (stmt=0x7ffff5a82c00) at
../../gcc-4.6.3/gcc/cfgexpand.c:2084
#7  0x0000000000569d3f in expand_gimple_basic_block
(bb=0x7ffff54fd888) at ../../gcc-4.6.3/gcc/cfgexpand.c:3626
#8  0x000000000056b0aa in gimple_expand_cfg () at
../../gcc-4.6.3/gcc/cfgexpand.c:4109
#9  0x0000000000750bed in execute_one_pass (pass=0x147f660) at
../../gcc-4.6.3/gcc/passes.c:1556
#10 0x0000000000750dc7 in execute_pass_list (pass=0x147f660) at
../../gcc-4.6.3/gcc/passes.c:1611
#11 0x0000000000886375 in tree_rest_of_compilation
(fndecl=0x7ffff572af00) at ../../gcc-4.6.3/gcc/tree-optimize.c:422
#12 0x0000000000a413ff in cgraph_expand_function (node=0x7ffff5632160)
at ../../gcc-4.6.3/gcc/cgraphunit.c:1576
#13 0x0000000000a415be in cgraph_expand_all_functions () at
../../gcc-4.6.3/gcc/cgraphunit.c:1635
#14 0x0000000000a41c27 in cgraph_optimize () at
../../gcc-4.6.3/gcc/cgraphunit.c:1899
#15 0x0000000000a40216 in cgraph_finalize_compilation_unit () at
../../gcc-4.6.3/gcc/cgraphunit.c:1096
#16 0x0000000000495d6b in c_write_global_declarations () at
../../gcc-4.6.3/gcc/c-decl.c:9878
#17 0x00000000008279d6 in compile_file () at ../../gcc-4.6.3/gcc/toplev.c:591
#18 0x00000000008298ee in do_compile () at ../../gcc-4.6.3/gcc/toplev.c:1900
#19 0x0000000000829a34 in toplev_main (argc=180, argv=0x7fffffffc7f8)
at ../../gcc-4.6.3/gcc/toplev.c:1963
#20 0x0000000000518e00 in main (argc=180, argv=0x7fffffffc7f8) at
../../gcc-4.6.3/gcc/main.c:36

Thanks
Samuel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]