This is the mail archive of the gcc-patches@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: Properly take address of SAVE_EXPR


Richard Kenner wrote:

> You don't only take addresses of things that are lvalues.
> You can take the address of a constant, for example.


It depends whether we are talking about semantics ("abstract
syntax tree") or a more medium-level (ABI) representation.
Semantically, you can take the address of an initialized read-only
anonymous variable.  But that is not the same thing as a constant,
at least conceptually.  (Some languages may magically coerce the
latter into the former, but that is a front-end issue, not a tree
issue.)

Now the ABI for dealing with some constant dats structures
might require them to be passed by reference.  But this I think
is another argument why SAVE_EXPR has poorly-defined semantics,
and should be deprecated in favor of (a proposed) LET_EXPR.
If you need to take the address of a constant, I think it should
be done this way:

   let TEMP : TYPE := CONSTANT
   in .... ADDR_EXPR (TEMP) ... ADDR_EXPR (TEMP)
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


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