https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80354
Alejandro Colomar <colomar.6.4.3 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |colomar.6.4.3 at gmail dot com --- Comment #10 from Alejandro Colomar <colomar.6.4.3 at gmail dot com> --- In some cases, that warning saved me from writing dangerous code (using file paths), and it's been very useful. But casting to void means one and only one thing: _I DO know what I'm doing and I do NOT care, so STFU!_ And if the casting to void is dangerous (ie. casting to void the result of storing a path), that's my fault. I currently have a program where I want, for some reason, to truncate the output to an 80-char line: #include <stdio.h> #define LINE_SIZE (80) int main(int argc, char *argv[]) { char truncated[LINE_SIZE]; (void)snprintf(truncated, LINE_SIZE, "I DO want to truncate this line " "to a 80 char line, and discard any remaining text so " "that it is not displayed or stored anywhere because I " "don't care about it. " " Usually one would check for the return value of " "snprintf, but in this precise situation, I do not " "care about it, so the explicit cast to (void) should " "silence the warning, just like it does in other " "warnings such as -Wunused-variable."); printf("%s\n", truncated); return 0; } But in the same project I have paths and that kind of uses of snprintf where I still want to have the warnings enabled (and even more, -Werror so that they never compile): if (snprintf(file_name, FILENAME_MAX, "%s/%s", file_path, saved_name)) { goto err_path; } Many other warnings are supressed with (void), why is this one so special? Anyways, I'm reporting a new bug, because this one is "RESOLVED INVALID".