This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14156] New: no warning for address of parameter
- From: "d dot binderman at virgin dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Feb 2004 09:56:27 -0000
- Subject: [Bug c++/14156] New: no warning for address of parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
// Given the following C++ source code
int * f( int a)
{
return &a;
}
int * g()
{
int b = 0;
return &b;
}
/*
then
[dcb@localhost src]$ ~/gnu/gcc333pre2/results/bin/g++ -c -g -O2 -Wall -ansi
-pedantic addrLocal.cc
addrLocal.cc: In function `int* g()':
addrLocal.cc:9: warning: address of local variable `b' returned
[dcb@localhost src]$
Note only one warning message.
G++ 333 pre release version 2 doesn't find the problem in function f.
G++ 332 also doesn't find the problem.
Here is Intel C++ doing what I want.
[dcb@localhost src]$ icc -c addrLocal.cc
addrLocal.cc(6): warning #1251: returning pointer to local variable
return &a;
^
addrLocal.cc(13): warning #1251: returning pointer to local variable
return &b;
^
This bug report boiled down from real code in Fedora Core 1.
*/
--
Summary: no warning for address of parameter
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: d dot binderman at virgin dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: linux / x86
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14156