[Bug c++/39551] New: C++ frontend not warn about unused dereference operator with -Wunused-value
lcwu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Mar 25 00:38:00 GMT 2009
Given the following code, where the value of the dereference operation is
unused,
$ cat unused_deref.c
void Foo(int* x) {
*x++;
}
if it is compiled with gcc (C frontend) with -Wunused-value option, we get a
warning.
$ gcc -Wunused-value -c unused_deref.c
unused_deref.c: In function 'Foo':
unused_deref.c:2: warning: value computed is not used
However, if the code is compiled with g++, we don't get the warning.
$ g++ -Wunused-value -c unused_deref.c
After doing some triage, it appears that C++ frontend silently gets rid of
INDIRECT_REF operator (without emitting any warnings) when it processes the
expression '*x++' in convert_to_void() in cp/cvt.c.
Here is the version string of the compiler that I tried:
gcc version 4.4.0 20090324 (experimental) (GCC)
--
Summary: C++ frontend not warn about unused dereference operator
with -Wunused-value
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lcwu at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39551
More information about the Gcc-bugs
mailing list