https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
--- Comment #29 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Paul Pluzhnikov from comment #28) > Well, that did expose the 30 bugs above, but unfortunately I can't do that > permanently, because it also exposed this false positive: > > assert(v.empty()); > > where assert in NDEBUG mode expanded into > > static_cast<void>(v.empty()); Isn't assert in NDEBUG mode guaranteed to not evaluate its argument? The above seems to violate that assumption. In C++ you could do this: template<typename T> inline T ignore_result(T x __attribute__((unused))) { return x; } extern int foo() __attribute__((warn_unused_result)); int main() { ignore_result(foo()); return 0; } Another alternative is to use #pragma GCC diagnostics push/ignored/pop. Ideally you could encapsulate that into a macro "ignore_result", but #pragma diagnostics does not work well in a macro definition yet (I cannot remember the PR number for this).