This is the mail archive of the gcc-bugs@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]

Bogus warning from egcs


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


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