[cfe-commits] r86252 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Checker.h lib/Analysis/CMakeLists.txt lib/Analysis/GRExprEngineInternalChecks.cpp lib/Analysis/GRExprEngineInternalChecks.h lib/Analysis/ReturnPointerRangeChecker.cpp test/Analysis/region-only-test.c

Cédric Venet cedric.venet at laposte.net
Fri Nov 6 14:02:05 PST 2009


>> +int a[10];
>> +
>> +int *f0() {
>> +  int *p = a+10;
>> +  return p; // expected-warning{{Return of Pointer Value Outside of
>> Expected Range}}
>> +}
>>
>>      

This could leads to false positive in case like:

struct Array10 {
     int a[10];
     typedef int* iterator;
     iterator begin() { return a; }
     iterator end() { return a+10; }
}

since while it is not allowed to dereference the p, it is legal to have 
a pointeur one element after the end.
On the other hand, only triggering the warning if the pointer is two 
elements (or more) after the end would limit the usefulness of the analysis.

regards,





More information about the cfe-commits mailing list