No -Wtautological-compare warning issued
| 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; }
Bad spelling correction. Read as: 'If there was no pointer dereference ...'.