[PATCH] Fix PR 14156, warning about returning addresses to parameters

Andrew Pinski pinskia@physics.uc.edu
Mon Feb 16 13:14:00 GMT 2004


Basically the problem is that the code does not check for parameters 
when
warning about the return was an address to a local variable.  This patch
fixes that by adding the check.

Thanks,
Andrew Pinski

OK? Bootstrapped on powerpc-apple-darwin7.2.0 with no regressions?
Ok for 3.4 also, even though this is not a regression but a two simple 
fix?
Okay for 3.3.4 also as again this is a simple fix?


ChangeLog:
	* c-typeck.c (c_expand_return): Add check for PARM_DECL.

cp/ChangeLog:
	* typeck.c (maybe_warn_about_returning_address_of_location):
	Add check for PARM_DECL.


Patch:

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: warning.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040216/504dec21/attachment.txt>
-------------- next part --------------



Testcase:

/* { dg-do compile  } */

int * f( int a)
{
	return &a; /* { dg-warning "address" "" } */
}

int * g()
{
	int b = 0;

	return &b; /* { dg-warning "address" "" } */
}


More information about the Gcc-patches mailing list