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]
Other format: [Raw text]

Re: Turning warning "returning reference to temporary" into error?


> > 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.
> 
> You are relying on undefined behavior here, dont you?


Sure, that's true from a technical point of view, but in fact this seems a
quite reasonable approach which is likely to work with most compilers. Obviously
there is no legitimate way to do this computation :-)


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