Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Another case of unnecessary "shift count is negative" warning #10246

Closed Quuxplusone closed 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR9920
Status RESOLVED DUPLICATE of bug 10030
Importance P normal
Reported by Dimitry Andric (dimitry@andric.com)
Reported on 2011-05-15 08:10:09 -0700
Last modified on 2011-10-07 05:56:12 -0700
Version trunk
Hardware All All
CC kremenek@apple.com, llvm-bugs@lists.llvm.org, mdf@FreeBSD.org
Fixed by commit(s)
Attachments pr5544c.c (117 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 6598
Trigger unneeded "shift count is negative" warning

[Creating this as a separate PR.]

This warning still appears while compiling the FreeBSD kernel source tree, even
with ToT, as reported to me by Matthew Fleming.  I just tested a further
reduced version of his sample with trunk r131368, and it gives:

pr5544c.c:4:17: warning: shift count is negative
unsigned data = W1(1);
                ^~~~~
pr5544c.c:2:47: note: instantiated from:
    (((_a) > 31 && (_a) < 64 ? (((unsigned) 1)<<((_a)-32)) : (unsigned) 0))
                                              ^ ~~~~~~~~~
1 warning generated.

Ted Kremenek said about this in bug 5544:

> The underlying problem is not that we don't prune these warnings on paths that
> can be shown to be dead.  The problem here is that Clang doesn't know this
> branch is dead.  The issue is how the CFG models || and && operations.  That's
> worth tracking in a separate bug.
Quuxplusone commented 13 years ago

Attached pr5544c.c (117 bytes, text/plain): Trigger unneeded "shift count is negative" warning

Quuxplusone commented 13 years ago

This can be addressed by improving the CFG's representation of && and ||, which would also help -Wuninitialized.

Quuxplusone commented 13 years ago

Note that changing the CFG format requires updating all clients: static analyzer, and dataflow-based warnings.

Quuxplusone commented 13 years ago

cloned to rdar://problem/9448836

Quuxplusone commented 13 years ago

Setting this as a duplicate of bug 10030. The problem only manifests itself with global initializations, so that PR has a much better description.

_This bug has been marked as a duplicate of bug 10030_