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: GCC's statement expression extension


>>>>> "Jamie" == Jamie Lokier <egcs@tantalophile.demon.co.uk> writes:

    Jamie> [Mark: the toupper example is not correct]

Why not?

I have:

  # define __tobody(c, f, a) 
    (__extension__							      
     ({ int __res;							      
	...						      
	__res = a[(int) (c)];						      
	__res; }))

If `c' is `(a + b).c_str()[0]' then a temporary will be created for `a
+ b' when `c' is used as an array index.  That temporary will be
destroyed at the end of the statement:

  __res = a[(int) (c)];

inside the statement expression, which is earlier than the end of the
enclosing full expression.

I'm happy to change the documentation, but I'm confused as to why you
think your original example doesn't illustrate the problem.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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