_must_check
Posted Nov 23, 2006 8:26 UTC (Thu) by
ldo (subscriber, #40946)
Parent article:
KHB: Automating bug hunting
I personally don't understand the point of _must_check. I would prefer to see a GCC option that caused all calls to functions that return non-void results to produce compile-time errors unless the result is
- used in an expression (including an assignment), or
- explicitly cast to void.
Thus, for example, a call to unlink(2) like this:
unlink(filename);
would be illegal. If you really wanted to ignore the result, you would have to write:
(void)unlink(filename);
which would make it clear to any reader that a function result was being thrown away.
(
Log in to post comments)