[PATCH] D135858: [clang][Interp] Support pointer arithmetic in binary operators

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 11:21:46 PDT 2022


shafik added inline comments.


================
Comment at: clang/test/AST/Interp/arrays.cpp:69
+constexpr int const * ap1 = &arr[0];
+constexpr int const * ap2 = ap1 + 3; // expected-error {{must be initialized by a constant expression}} \
+                                     // expected-note {{cannot refer to element 3 of array of 2}} \
----------------
We should also have a test for addition out of bounds but subsequent addition bringing it back in bounds. Still UB but we should verify it: https://godbolt.org/z/c1MWjGdfT

Apparently gcc does not catch this one.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135858/new/

https://reviews.llvm.org/D135858



More information about the cfe-commits mailing list