On Wed, Jul 20, 2011 at 11:39 AM, Kaelyn Uhrain <[email protected]> wrote: > I've attached an updated version of my patch that better handles cases where > pointer arithmetic is done after casting a constant-size array to a pointer > for a smaller base type (e.g. casting an int array to char*). Of the pointer > arithmetic warnings, about 24% could be considered false positives; however, > the actual number of false positives is quite small and 2/3 of them stem > from the use of a single macro--if you count those as a single warning & > false positive, the rate drops to 17%. Of the false positives most are from > semi-questionable pointer arithmetic where a constant greater than the > length of the array/pointer is being added to the pointer and some int > 1 > being subtracted from it, e.g.: > > 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, but it has undefined behavior, and the IR we generate for it has undefined behavior. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
