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

Wolfgang Bangerth bangerth@ticam.utexas.edu
Thu Mar 6 23:06:00 GMT 2003


The following reply was made to PR c++/9881; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Richard C Bilson <rcbilson@plg2.math.uwaterloo.ca>
Cc: asharji@uwaterloo.ca, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>,
   <pabuhr@uwaterloo.ca>, <nathan@codesourcery.com>
Subject: Re: c++/9881: What is an address constant expression?
Date: Thu, 6 Mar 2003 17:00:49 -0600 (CST)

 [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@codesourcery.com>
 > 2002-08-15  Nathan Sidwell  <nathan@codesourcery.com>
 
 Thanks for this very good detective work of figuring out which patch 
 caused the problem!
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 



More information about the Gcc-prs mailing list