https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114104
Harald van Dijk <harald at gigawatt dot nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> --- Isn't this behaving as designed as far as nodiscard goes? x != 0 is defined to be evaluated as !(x == 0) per [over.match.oper]p9, where the result of x == 0 is not a discarded-value expression, and therefore nodiscard suggests no warning for it. That said, there is a missing general warning in GCC about the built-in ! operator being discarded: bool f(); int main() { !f(); // clang: warning: expression result unused [-Wunused-value] // gcc: no warning } For similar useless operations, such as f() ^ true;, GCC emits a similar warning "warning: value computed is not used [-Wunused-value]". Presumably, if that warning were implemented in GCC for ! as well, it should also fire for your original x != 0 test?