This is the mail archive of the gcc@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]

static initializers and fold()


Hi,

My new Mercury front-end crashed for one of my test cases
where I try to generate a global variable whose initializer
is `0 << 4'.

The symptom is that it dies in get_last_insn(), called from expand_binop(),
because cfun is a null pointer. 

The fact that `cfun' is a null pointer looks right, since this
is not inside any function.

I think this is because I didn't call fold() on the expression,
and that the gcc back-end has the undocumented requirement that
the front-end call fold() on initializers for global variables.
(Or perhaps on all expressions that it constructs?)

Does this diagnosis sound correct?

If so, would it be a good idea to add some documentation about this
somewhere?  Perhaps in tree.def?

P.S.  Here's a stack trace.

#0  get_last_insn () at emit-rtl.c:2066
#1  0x80c399f in expand_binop (mode=SImode, binoptab=0x8978178, op0=0x401cc200, op1=0x401cc210,
    target=0x0, unsignedp=0, methods=OPTAB_DIRECT) at optabs.c:634
#2  0x80bd0df in expand_shift (code=LSHIFT_EXPR, mode=SImode, shifted=0x401cc200,
    amount=0x4022ce80, target=0x0, unsignedp=0) at expmed.c:2019
#3  0x80a7488 in expand_expr (exp=0x4022cea0, target=0x0, tmode=VOIDmode,
    modifier=EXPAND_INITIALIZER) at expr.c:7747
#4  0x80a4ad9 in expand_expr (exp=0x4022cec0, target=0x0, tmode=VOIDmode,
    modifier=EXPAND_INITIALIZER) at expr.c:7345
#5  0x80dda9b in output_constant (exp=0x4022cec0, size=4) at varasm.c:4347
#6  0x80de5d7 in output_constructor (exp=0x4022cf60, size=4) at varasm.c:4608
#7  0x80ddc3d in output_constant (exp=0x4022cf60, size=4) at varasm.c:4395
#8  0x80d7f0c in assemble_variable (decl=0x4022d080, top_level=1, at_end=0, dont_output_data=0)
    at varasm.c:1639
#9  0x8263013 in rest_of_decl_compilation (decl=0x4022d080, asmspec=0x0, top_level=1, at_end=0)
    at ./toplev.c:2584
...

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

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