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]

Re: static initializers and fold()




  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


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