On Thu, Jul 21, 2011 at 1:44 PM, David Blaikie <[email protected]> wrote: >>> void foo(int n) { >>> char x[5]; >>> if (n > 0) bar(x + 6 - n); >>> } >> >> Strictly speaking, that isn't a false positive... I can't think of how >> we would actually produce anything other than the expected result, > > [I'm not sure how closely you were considering your knowledge of the > implementation of clang (which is no doubt greater than my own) > compared to things a C++ compiler could possibly do, even if clang > doesn't do them today.] > > Actually it's not so hard to imagine a case just like this where this > UB could result in some interesting results. It wouldn't be hard for > the compiler to prove that x + 6 is out of range, therefor the > condition (n > 0) must always be false, so it could just remove the > code entirely. Chris gave some similar examples in his blog series on > UB.
Right... I was mostly considering clang's implementation; we don't aggressively transform provably undefined GEP's, at least at the moment. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
