Addresses https://bugs.llvm.org/show_bug.cgi?id=36206
rdar://37159026
A proper fix would be much harder, and would involve changing the appropriate code in ExprEngine to be aware of the size limitations of the type used for addressing.
Differential D43218
[analyzer] Quickfix: do not overflow in calculating offset in RegionManager george.karpenkov on Feb 12 2018, 6:32 PM. Authored by
Details Addresses https://bugs.llvm.org/show_bug.cgi?id=36206 rdar://37159026 A proper fix would be much harder, and would involve changing the appropriate code in ExprEngine to be aware of the size limitations of the type used for addressing.
Diff Detail Event Timeline
Comment Actions We have a comment documenting the decision. Adding a printf doesn't seem like it would help very much here and adds untested code. I don't think we should have a policy of adding these printfs on every early return. Since these printfs make it harder to read the code and are duplicated with the comments, I think we should avoid adding one until we know it is actually generally useful. Here is what I propose:
Comment Actions Dunno, it'd be great to come up with some systematic approach to those debug prints. Having some of them is really nice sometimes. I also wish the informal // no-crash thingy was specifically saying that it's about not causing a UBSan error, not just a simple assertion failure or segfault that the reader would expect. Because we don't have many such tests, so the reader doesn't expect that, and a quick glimpse at the differential revision may not be enough to figure this out. Comment Actions ...turns out the previous version had a bug. Re-introduced logging, as I've needed that for the second time for debugging. This version is more robust, and is more obvious, but function is considerably more generic, except I don't know a good place to put it (and it can't be MathExtras, since APInt depends on that). Comment Actions @vsk on the other hand if circular dependency between MathExtras and APInt is OK, I guess the code could be moved there. Comment Actions Sure. As I mentioned off-list, I think it would be cleaner to implement these checked operations as overloads of SaturatingAdd, SaturatingMultiply, etc. I don't anticipate a build dependency issue there.
|
Oh, aren't sizes non-negative? Why not just cast to unsigned and use SaturatingMultiplyAdd, or something?