https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29280

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #5)
> It seems like it should be trivial to enhance the warning by adding a note
> with the suggestion(s) mentioned in the request.

Given all the cases mentioned in PR25733, we should find a better way for users
to silence the warning. For example, by using an explicit cast.

Example:

int foo(int a, int b)
{
    return ((a = b) ? 1 : 0);  // <= missed warning.
}

warning: using the result of an assignment as a boolean expression
[-Wparentheses]
     return ((a = b) ? 1 : 0);
              ~~^~~
note: add an explicit cast to bool to silence this warning
     return ((a = b) ? 1 : 0);
              ^
              (bool)

note: use '==' to turn this assignment into an equality comparison
     return ((a = b) ? 1 : 0);
                ^
                ==

Reply via email to