This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Turning warning "returning reference to temporary" into error?
- From: Eyal Lebedinsky <eyal at eyal dot emu dot id dot au>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 12 May 2003 10:01:15 +1000
- Subject: Re: Turning warning "returning reference to temporary" into error?
- Organization: Eyal at Home
- References: <Pine.LNX.4.44.0305111936530.560-100000@goofy>
Richard Guenther wrote:
> Wouldnt it be a good idea to at least turn the
> maybe_warn_about_returning_address_of_local warnings into an error with
> -pedantic? Or always?
Let me show you an example where I use it. A function has a large object
on the stack which it initialises and returns the address of when called
for the first time.
On a later call it checks how much of it was overwritten and returns
this
number of an estimate of how much stack was used suring the time since
the first call.
Now, I could go through some hoops to hide the fact that I am returning
the adress of an auto, but I prefer not too. And I am OK with seeing
the warning too.
May be crude, but works very reliably.
--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>