> Now that we have a way of explicitly marking a variable as dead, we
> can use that to indicate the end of a temporary's lifetime by adding
> it as a cleanup for that temporary.  Since gimple_push_cleanup still
> deals in trees I needed to tweak a couple of places to avoid trying
> to treat a clobber as a real CONSTRUCTOR, but the changes were small.
> 
> One somewhat surprising thing that showed up as a result of this
> change were some failures in the libstdc++ testsuite.  When I
> investigated, I found that the tests were relying on temporaries
> living longer than they should:
> 
> >  const int& x = std::max(1, 2);
> 
> Since std::max takes its arguments by const reference and returns one
> of them, x ends up as a dangling reference to the temporary
> containing 2, which dies at the end of the declaration-statement.
> This patch breaks the testcase because now the temporary stack slots
> get reused by the next statement, so by the time we look at x it no
> longer points to a 2. I've fixed the tests by removing the references
> on the variables.

Interesting. Thanks for the heads up. This should definitely be
mentioned in 4.7/porting_to.html.

-benjamin

Reply via email to