llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

No -Wtautological-compare warning issued

Open riyazvp opened this issue 8 years ago • 1 comments

Bugzilla Link 37113
Version 6.0
OS All

Extended Description

For the following simple test case, clang fails to issue a -Wtautological-compare warning. gcc 6.2 issues this warning.

If there was no pointer deference (and there was a self compare on a simple int), then clang would issue the warning as expected. The pointed memory is not volatile and clang -O1 optimizes away the two comparisons that would always evaluate to false. So it is reasonable to expect that it should warn about them as well.

struct Foo { int a; };

int cmp(const Foo* x, const Foo* y); int cmp(const Foo* x, const Foo* y) { if (x->a < x->a) { return -1; } else if (y->a > y->a) { return 1; } return 0; }

riyazvp avatar Apr 12 '18 19:04 riyazvp

Bad spelling correction. Read as: 'If there was no pointer dereference ...'.

riyazvp avatar Apr 12 '18 19:04 riyazvp