[Bug c++/14156] New: no warning for address of parameter
d dot binderman at virgin dot net
gcc-bugzilla@gcc.gnu.org
Mon Feb 16 09:56:00 GMT 2004
// 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
More information about the Gcc-bugs
mailing list