This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>, Jason Merrill <jason at redhat dot com>
- Date: Tue, 14 Jul 2015 22:30:06 +0100
- Subject: Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
- Authentication-results: sourceware.org; auth=none
- References: <20150714151813 dot GA2363 at redhat dot com>
Marek Polacek <polacek@redhat.com> writes:
> + /* Don't warn for e.g.
> + HOST_WIDE_INT n;
> + ...
> + if (n == (long) n) ...
> + */
> + if ((CONVERT_EXPR_P (lhs) || TREE_CODE (lhs) == NON_LVALUE_EXPR)
> + ^ (CONVERT_EXPR_P (rhs) || TREE_CODE (rhs) == NON_LVALUE_EXPR))
> + return;
I might be misreading it, sorry, but it looks like the XOR means that
we'd still warn for:
if ((HOST_WIDE_INT) n == (long) n) ...
in cases where HOST_WIDE_INT and long have the same precision.
Thanks,
Richard