C unsed results warning when optiming
Bug #1837329 reported by
Bill Pringlemeir
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-7 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Here is a sample program,
printf "#include <sys/uio.h>\nvoid foo(void) {\n (void)writev(1, (void*)0, 0);\n }\n" | gcc -Wall -Wformat=2 -Wshadow -O1 -c -xc - -o foo.o
If you change to '-O0', there is no warning. I have x86_64 but I doubt that matters? The issue is to have the warnings, but ignore by casting the result for that particular case (next statement is abort()).
The same things happens in 4.8, 4.9, and version 5. Maybe this is desired?
To post a comment you must log in.
I found the gcc bugzilla thread. https:/ /gcc.gnu. org/bugzilla/ show_bug. cgi?id= 66425
It is weird that optimization affects the warning?
I was hoping the `(void)` would get rid of it for just this case.
You can close if you believe the optimization should affect the warnings given. Probably the pass to report it is not executed at level 0.