This is the mail archive of the gcc-patches@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: [PATCH] Fix PR43379


On Wed, 17 Mar 2010, Richard Guenther wrote:

> On Tue, 16 Mar 2010, Jeff Law wrote:
> 
> > On 03/16/10 14:08, Joseph S. Myers wrote:
> > > On Tue, 16 Mar 2010, H.J. Lu wrote:
> > > 
> > >    
> > > > We are warning return of label as local variable. This patch fixes it,.
> > > >      
> > > Are you sure this is a bug?  Returning the address of a local label seems
> > > exactly as problematic as returning the address of a local variable; the
> > > diagnostic should say "label" not "variable", and it should be possible to
> > > disable it, but the uses of doing so are fairly specialized and
> > > non-portable in both cases (reporting addresses of particular code in a
> > > function, or of a stack location from a function call); you can't jump to
> > > the returned address of a label, or dereference the returned address of a
> > > variable.
> > >    
> > The address of a local label is marginally less problematic than returning the
> > address of a local variable.    In the former case you're returning a code
> > address, which is presumably still valid and perhaps useful (though the
> > context necessary to reasonably execute those instructions is may no longer be
> > available).  In the latter case the stack frame has been deallocated and could
> > easily have been smashed by an interrupt, subsequent caller, etc, etc.
> > 
> > I'd certainly agree that both are, at best, highly unportable and should
> > trigger a warning.
> 
> Indeed.  I'll just move the testcase to dg-torture and add -w.

Like the following.  Committed to trunk.

Richard.

2010-03-17  Richard Guenther  <rguenther@suse.de>

	* gcc.dg/pr43379.c: Add -w.

Index: gcc/testsuite/gcc.dg/pr43379.c
===================================================================
*** gcc/testsuite/gcc.dg/pr43379.c	(revision 157512)
--- gcc/testsuite/gcc.dg/pr43379.c	(working copy)
***************
*** 1,5 ****
  /* { dg-do compile } */
! /* { dg-options "-O2 -ftracer" } */
  
  void *foo(int i, int *p)
  {
--- 1,5 ----
  /* { dg-do compile } */
! /* { dg-options "-O2 -ftracer -w" } */
  
  void *foo(int i, int *p)
  {


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