[Bug c++/12668] Strange warnings with -O1 -Wunreachable-code in 3.3.1,3.3.2,3.4
rmerkert at alphatech dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 18 13:51:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12668
------- Additional Comments From rmerkert at alphatech dot com 2003-10-18 13:24 -------
I still think that the warning is not very helpful. Consider this program instead:
cat > test.c <<EOF
inline void foo (int x)
{
if (x!=0)
x = x + 1;
}
int main ()
{
foo(-1);
foo(0);
foo(1);
foo(2);
return 0;
}
EOF
gcc -O1 test.c -Wunreachable-code
This will give exactly the same warning as before:
main.c: In function `main':
main.c:4: warning: will never be executed
The warning is completely useless. The warning is not even pointing me to the
root cause which is the call to foo(0).
I think that the warning should be something like this:
main.c: In function `main':
main.c:10: warning: call to foo has been optimized away
More information about the Gcc-bugs
mailing list