Is it possible to make gcc descriptors of unused values ββfor C, as g ++ handles them for C ++? There p && ++*p;is a warning for type instructions in C, but not for C ++. Setting -wno-unused-valueup is not really a solution, as it will also remove useful warnings (as in line 2 below). Example:
$ (gcc --version|head -1; ls -l qwe.*; cat qwe.x; echo $sep; gcc -c -O2 -Wall qwe.c; echo $sep; g++ -c -O2 -Wall qwe.cc) 2>&1 | sed 's/^/ /'
gcc (Debian 4.9.2-10) 4.9.2
lrwxrwxrwx 1 tml tml 5 Jul 23 10:12 qwe.c -> qwe.x
lrwxrwxrwx 1 tml tml 5 Jul 23 10:12 qwe.cc -> qwe.x
-rw-r--r-- 1 tml tml 1384 Jul 23 10:49 qwe.o
-rw-r--r-- 1 tml tml 55 Jul 23 10:49 qwe.x
void g(int *p) { p && ++*p; }
void f(int *p) { *p+5; }
-------------------------------------------
qwe.c: In function βgβ:
qwe.c:1:20: warning: value computed is not used [-Wunused-value]
void g(int *p) { p && ++*p; }
^
qwe.c: In function βfβ:
qwe.c:2:18: warning: statement with no effect [-Wunused-value]
void f(int *p) { *p+5; }
^
-------------------------------------------
qwe.cc: In function βvoid f(int*)β:
qwe.cc:2:20: warning: statement has no effect [-Wunused-value]
void f(int *p) { *p+5; }
^
source
share