[clang] [clang][analyzer] Add notes to PointerSubChecker (PR #95899)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 19 02:20:30 PDT 2024
================
@@ -32,3 +32,20 @@ void different_2() {
int d = p2 - p1; // expected-warning{{Subtraction of two pointers that do not point into the same array is undefined behavior}} \
// expected-note{{Subtraction of two pointers that do not point into the same array is undefined behavior}}
}
+
+int different_3() {
+ struct {
+ int array[5];
+ } a, b;
+ return &a.array[3] - &b.array[2]; // expected-warning{{Subtraction of two pointers that do not point into the same array is undefined behavior}} \
+ // expected-note{{Subtraction of two pointers that do not point into the same array is undefined behavior}}
+}
+
+int different_5() {
----------------
NagyDonat wrote:
```suggestion
int different_4() {
```
Very minor nitpick: `different_3` was followed by `different_5`.
https://github.com/llvm/llvm-project/pull/95899
More information about the cfe-commits
mailing list