4 ms·
These are, or used to be, quite common with gcc. Unused-result warnings require dataflow analysis to run to determine whether the values are used, and on no-opt
by pm215 9y ago
These are, or used to be, quite common with gcc. Unused-result warnings require dataflow analysis to run to determine whether the values are used, and on no-optimisation compiles gcc didn't bother to do dataflow analysis.
Conversely, here's one where a warning is produced only without -O2:
orth$ cat z.c
int foo (int a) {
int x;
if (a == 5) { x = 3; return 42; }
return x;
}
orth$ gcc -O2 -Wall -o z.o -c z.c
orth$ gcc -Wall -o z.o -c z.c
z.c: In function ‘foo’:
z.c:4:4: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return x;
^
orth$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2