Comment 20 for bug 827990

Revision history for this message
In , Ebotcazou (ebotcazou) wrote :

> and we have a CTOR and not individual initializations because of Erics
> const-pool changes I believe.

No, we have the constructor with GCC 4.5 as well, my patch only makes it go through tree_output_constant_def.

> &p->a is folded to &1241530624B->a even before gimplification (but
> &1241530624B->a is "unfolded" - it's an obfuscated constant).
>
> We ICE from
>
> #0 fancy_abort (
> file=0x1252a70 "/space/rguenther/src/svn/gcc-4_6-branch/gcc/varasm.c",
> line=2638, function=0x1253700 "decode_addr_const")
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/diagnostic.c:893
> #1 0x0000000000ca9016 in decode_addr_const (exp=0x2aaaaceb3fc0,
> value=0x7fffffff9b30)
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/varasm.c:2638
> #2 0x0000000000ca97f0 in const_hash_1 (exp=0x2aaaaceb3fc0)
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/varasm.c:2734
> #3 0x0000000000ca95db in const_hash_1 (exp=0x2aaaacea54e0)
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/varasm.c:2724
> #4 0x0000000000cace7a in tree_output_constant_def (exp=0x2aaaacea54e0)
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/varasm.c:3302
> #5 0x000000000083a5f4 in gimplify_init_constructor (expr_p=0x7fffffffb3a8,
> pre_p=0x7fffffffccf8, post_p=0x7fffffffa928, want_value=0 '\000',
> notify_temp_creation=0 '\000')
> at /space/rguenther/src/svn/gcc-4_6-branch/gcc/gimplify.c:3833
>
> and fold &p->a via c_fully_fold_internal.

This is a known issue, namely that tree_output_constant_def rejects offsetof computations. See PR middle-end/44100 for an example with the C++ compiler.

I think this should be folded in the front-end - c_fully_fold is kind of a misnomer if it can only partially fold &p->a. It's just a matter of copying
the chunk of code present in build_unary_op, no big deal IMO.

And this compiles fine in C++ because the folding is done:

Starting program: /home/eric/build/gcc/native/gcc/cc1plus -quiet pr50266.c -quiet -mtune=generic -march=x86-64 -Os

Breakpoint 1, tree_output_constant_def (exp=0x7ffff6edbdf8)
    at /home/eric/svn/gcc/gcc/varasm.c:3295
3295 key.value = exp;
(gdb) p debug_generic_expr(exp)
{1241530624B, 1241530628B, 0B}