On 7/16/24 10:31 AM, Eric Gallager wrote:
On Mon, Jul 15, 2024 at 10:37 PM Patrick Palka <ppa...@redhat.com> wrote:

Bootstrapped andrregtested on x86_64-pc-linux-gnu, does this look
OK for trunk?

-- >8 --

Here we're neglecting to emit a -Wunused-value for eligible ! operator
expressions, and in turn for != operator expressions that are rewritten
as !(x == y), only because we don't call warn_if_unused_value on
TRUTH_NOT_EXPR since its class is tcc_expression.  This patch makes us
consider warning for TRUTH_NOT_EXPR as well.


Eh, I think I've seen the ! operator recommended as a way to silence
-Wunused-value previously in cases where an actual fix isn't
practical; some people might be mad about this...

That sounds like weird advice to me; I'd expect the result of ! to be used, and we already warn if the operand is something other than bool. Clang also warns for the bool case.

Seems like ADDR_EXPR is another tcc_expression that could use handling here, e.g.

struct A { int i; };
A& f();
int main() {
  &f().i; // missed warning
}

Jason

Reply via email to