This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12668] Strange warnings with -O1 -Wunreachable-code in 3.3.1,3.3.2,3.4
- From: "rmerkert at alphatech dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Oct 2003 13:24:19 -0000
- Subject: [Bug c++/12668] Strange warnings with -O1 -Wunreachable-code in 3.3.1,3.3.2,3.4
- References: <20031018040741.12668.rmerkert@alphatech.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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