TFW casing the return of a function to void is considered "ignoring" it's return value. I mean, YES, it is, but, no, not really.
Conversation
But of course, assigning it to a local variable that never gets read ISN'T ignoring it though.
BAD:
(void)strobe_randomize(&rng_save, rng_save_len);
GOOD:
{
int r;
r = strobe_randomize(&rng_save, rng_save_len);
}
*facepalm*
1
1
2
Replying to
GCC warns for this but Clang treats it as explicitly silencing the warning due to that being the convention.
Replying to
I forgot to turn on -Werror -Wall, and of course the above complains:
error: variable 'r' set but not used
which required a (void)r to silence.
IMO clang's behavior is correct here.
1
I'm also probably a crazy one for thinking that it should be an error to ignore the return value in ALL cases. And that you have to (void) it out if you really want to not check the possible error that the function returns.
1
Show replies

