This is the mail archive of the
mailing list for the GCC project.
Re: Warn when returning the address of a temporary (middle-end) v2
- From: Jeff Law <law at redhat dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 02 Jul 2014 16:46:22 -0600
- Subject: Re: Warn when returning the address of a temporary (middle-end) v2
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1406221930380 dot 20514 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 10 dot 1406291111050 dot 2096 at laptop-mg dot saclay dot inria dot fr> <53B1D0C5 dot 30901 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1406302319090 dot 2048 at laptop-mg dot saclay dot inria dot fr>
On 06/30/14 15:37, Marc Glisse wrote:
The slot exists, but its contents are undefined. The caller never even
knows if the callee ever flushed an object back to those slots or if it
did flush back, which objects were flushed and in what state.
On Mon, 30 Jun 2014, Jeff Law wrote:
On 06/29/14 03:22, Marc Glisse wrote:
After looking at PR 61597, I updated the 2 conditions to:
+ if ((TREE_CODE (valbase) == VAR_DECL
+ && !is_global_var (valbase))
+ || TREE_CODE (valbase) == PARM_DECL)
a PARM_DECL is a local variable and returning its address is wrong,
Right. It can live in either a caller or callee allocated slot.
The "caller" case scares me a bit. Is it really wrong to return the
address in that case? The slot still exists after returning if the
caller is responsible for it.
There was a time when I was pondering using those slots for saving
callee saved registers on the PA so that leafs that needed a few stack
slots wouldn't need to allococate a new frame, instead it'd just use
those convenient 4 words. But this turned out to just not be important
and it would totally hose the unwinding mechanisms that were in use on
the PA at the time.