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]
Other format: [Raw text]

Re: statement expressions and extended asm bug?


On Tue, Mar 16, 2004 at 05:54:04PM +0000, Nathan Sidwell wrote:
> Gunther Nikl wrote:
> >On Mon, Mar 15, 2004 at 05:50:36PM +0000, Nathan Sidwell wrote:
> 
> >>(in g++, statement expressions always produce a result 'as-if' by
> >>'return').
> >
> >  Does that mean with g++ it should work? I just tried with 3.3 and it
> >  doesn't.
> It seems that those changes didn't make it to 3.3, but will be in 3.4.
> See PR 11295 for details

  Yes, with g++ 3.4 my testcase showed the expected behaviour.

> >>Perhaps your rewriting of the asm is effectively making the same change.
> >  AFAICT from the discussion so far, even if it works with the nested
> >  s-e's, its still wrong.
> I think the nested s-e's are ok.

  Good.

> >>Your example is IMHO another case of why statement-exprs should return
> >>rvalues!
> >  And then I could use s-e as a function argument as I did?
> only the nested ones,

  Thats fine and no problem. I can make sure that only nested s-e are
  used when returning a value.

> >On Tue, Mar 16, 2004 at 09:12:15AM +0000, Nathan Sidwell wrote:
> >
> >>Having statement expressions silently extend the lifetime of an lvalue
> >>declared within is a great way to trip users up.
> >  Is that "my" problem?
> er, sort of. IMHO it is a bug in the mechanism by which s-e's return
> values, and you have fallen over it by your use of the register asm
> variable.

  Do you think I should file a PR? It seems to be a good idea doing that.

  To avoid the local explict register variable completely: Would it be
  possible to combine an asm() statement (getting all inputs in local
  explicit register variables, no outputs and clobbers) and a C expression
  doing the real call? Thats what I already mentioned in an eralier mail.
  In that case one wouldn't need the local explicit register variable for
  the return value. However, I am not sure that this would work reliable.
  As long as the call comes immediately after the asm (a jump to the real
  call would be ok) it should be fine.

  Gunther


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