This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)


On 07/22/2015 01:06 PM, Marek Polacek wrote:
On Wed, Jul 22, 2015 at 12:43:53PM -0600, Martin Sebor wrote:
On 07/14/2015 09:18 AM, Marek Polacek wrote:
Code such as "if (i == i)" is hardly ever desirable, so we should be able
to warn about this to prevent dumb mistakes.

I haven't tried the patch or even studied it very carefully but
I wonder if this is also the case when i is declared volatile.
I.e., do we want to issue a warning there? (If we do, the text
of the warning would need to be adjusted in those cases since
the expression need not evaluate to true.)

We don't warn for volatiles because operand_equal_p doesn't consider
decls with side effects as same.  Admittedly the test doesn't test
that...

I see. Thanks for clarifying that. Not warning makes sense. I would
suggest to add a test case for it then to make sure it's deliberate.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]