This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's statement expression extension
On Jul 29, 2000, Mark Mitchell <mark@codesourcery.com> wrote:
> X x;
> X f();
> x = ({ f(); });
> Oops. The return value of f() got destroyed before we got a chance to
> copy it.
I see. We'd have to have copied it to some temporary that would hold
the result of the statement expression before calling its destructor.
But we'd have to special-case this copy to only be done for the last
statement of a statement-expression. Too bad.
Maybe the way to go is to require statement expressions to contain
explicit `return' statements, at least in C++. This would at least
make it easier to support them in C++. Is `return' currently usable
within statement expressions?
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me