Open Quuxplusone opened 13 years ago
Bugzilla Link | PR9200 |
Status | NEW |
Importance | P normal |
Reported by | David Chisnall (csdavec@swan.ac.uk) |
Reported on | 2011-02-11 06:23:12 -0800 |
Last modified on | 2011-06-06 16:38:07 -0700 |
Version | trunk |
Hardware | PC All |
CC | jrose@belkadan.com, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Well, no, in theory "end - ptr" could be -1, which then gets implicitly
converted to an unsigned after the comparison has finished. If you cast "end -
ptr" to unsigned before the comparison, or even test that ptr < end instead of
==, there should be no warning. But with just your example I can't reproduce
the warning.
// This analyzes cleanly...am I missing something?
void x (int *y, int *z) {
if (y == z) return;
unsigned len = (y - z) < 32 ? (y - z) : 31;
char buf[len+1];
}
(I believe the analyzer still assumes -fwrapv semantics all the time, so
converting -1 into unsigned can still give a zero value when you add 1.)