This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bogus warning from egcs
- To: egcs-bugs at cygnus dot com
- Subject: Bogus warning from egcs
- From: Christopher Grinton <cgg at osa dot com dot au>
- Date: Wed, 22 Oct 1997 10:08:47 +1000
The following function generates a bogus warning when compiled with
"g++ -Wall":
int&
f()
{
static int i;
void* p = &i;
return *static_cast<int*>(p);
// return *(int*)p;
}
$ g+ -c -Wall t.cxx
t.cxx: In function `int & f()':
t.cxx:5: warning: reference to local variable `p' returned
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.13/specs
gcc version egcs-2.90.13 971016 (gcc2-970802 experimental)
g++ 2.7.2 does not generate any warning, and as far as I can tell, the
warning is incorrect.
Using an old-style cast rather than the static_cast<> also produces
this warning.
Regards,
Chris