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

Re: c++/9881: What is an address constant expression?


[I cc:ed Nathan, since he might know what's going on better than at least 
me.]

> >     I think this is now analyzed. We need a language lawyer
> >     to look at it.
> 
> Before we start bashing each other over the head with our respective
> copies of the standard,

Well, I apologize if I seemed as if I wanted to. At least to me, it was
not at all clear what might be the reasoning why this testcase might or
should not fail. I think at least we now know which clauses are relevant,
and what is the question that must be decided.

> Clearly, section 3.6.2 of the standard permits an implementation to
> compute static initializers at compile time even if no other part of
> the standard requires it to do so.  Even if the desired behavior is
> not mandated by the standard, it's still a beneficial optimization,
> provided that gcc wasn't generating incorrect code because of it. 

While that is true, it is not the question here: the standard mandates to 
initialize 
- first dynamic data by zero
- then, constant initialized data by their value
- finally, dynamic data by their dynamically computed initializer
If the compiler can shortcut computations for the last category, it must 
not start initialization before the second class is completed, 
nevertheless. 

In the testcase, an element of the second class has slipped into the
third. The question I couldn't answer was whether it belongs to class 2 or 
3. If it is 3, then the previous behavior was in error. If it is 2, then 
the present behavior is a regression.


> Previously, the constant_flag was set for the expression in question (that
> is, &((bar*)&module::storage)->p) by the function build_component_addr
> in cp/typecheck.c.  This function was removed from the 3.3 branch:
> 
> 2002-08-08  Nathan Sidwell  <nathan at codesourcery dot com>
> 2002-08-15  Nathan Sidwell  <nathan at codesourcery dot com>

Thanks for this very good detective work of figuring out which patch 
caused the problem!

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth             email:            bangerth at ticam dot utexas dot edu
                              www: http://www.ticam.utexas.edu/~bangerth/



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