This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: static initializers and fold()
- To: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Subject: Re: static initializers and fold()
- From: Jeffrey A Law <law at redhat dot com>
- Date: Mon, 08 Jan 2001 16:07:41 -0700
- cc: gcc at gcc dot gnu dot org
- Reply-To: law at redhat dot com
In message <20010102033109.A18633@hg.cs.mu.oz.au>you write:
> 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'.
Sounds like you didn't fold the initializer :-)
> The symptom is that it dies in get_last_insn(), called from expand_binop(),
> because cfun is a null pointer.
Yup -- that indicates that you're trying to generate RTL to compute some
value even though you're not in the process of compiling any specific
function.
That (of course) won't work because you've got no way to execute those
insns to initialize the variable at runtime.
> The fact that `cfun' is a null pointer looks right, since this
> is not inside any function.
Correct.
> 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.
I believe you're correct in that:
a. global initializers for globals need to be compile-time constants
or relocatable + compile-time constants.
b. The front-end needs to fold the expression to evaluate any
expressions to collapse expressions into a constant.
> If so, would it be a good idea to add some documentation about this
> somewhere? Perhaps in tree.def?
No idea.
jeff