[PATCH] D149149: [clang][Interp] Check one-past-the-end pointers in GetPtrField

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 3 05:14:21 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/test/AST/Interp/records.cpp:500
 
 namespace PointerArith {
   struct A {};
----------------
shafik wrote:
> aaron.ballman wrote:
> > Neat! For the tests in this namespace, Clang and ICC agree, GCC and MSVC agree, and users get to cry: https://godbolt.org/z/7EWWrY5z6
> Yeah, unfortunate but I am pretty sure clang is correct on both of those.
I think Clang is correct on one of those, but not both of them. I think Clang is correct to reject `constexpr const int *pn = &(&b + 1)->n;` as that involves dereferencing the one-past-the-end pointer, but I think Clang is wrong to reject `constexpr A *a2 = &b + 1;` as there's no dereference there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149149



More information about the cfe-commits mailing list