On Tue, Jul 16, 2024 at 10:50 AM Jason Merrill <ja...@redhat.com> wrote:
>
> 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.
>

It's possible that I was getting -Wunused-value confused with
-Wunused-result when I was remembering the advice I'd heard:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

> 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