-Wunused-result
enabled by default : since you will need to decorate the function with __attribute__ ((warn_unused_result))
to trigger a warning, false positive effects only occur when they are used too liberally.
Even without passing additional flags, gcc should give a warning. However, as Mat explained, the compiler does not perform the necessary control flow analysis without increasing optimization levels.
Correct your code or disable the warning by adding -Wno-unused-result
. Most likely will add a void
value.
To drown out a warning in your code, you need to assign a return value to a dummy variable, which you can then apply to void
to avoid a new warning about an unused variable. It is also possible to substitute a literary instance of C99 for an explicitly declared variable (verified with gcc 4.5.3).
This is really not optimal - I really expected the void
-cast originally created to work ...
source share