[PATCH] D149013: [clang][Interp] Check pointers when accessing base class
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 2 13:54:19 PDT 2023
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang/test/AST/Interp/records.cpp:509-512
+ constexpr A *a2 = &b + 1; // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{cannot access base class of pointer past the end of object}} \
+ // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{cannot access base class of pointer past the end of object}}
----------------
I may have jumped the gun on accepting this, actually. Forming the pointer to `&b + 1` is fine, but evaluating it by dereferencing it would be UB. e.g., http://eel.is/c++draft/expr.const#13.3
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149013/new/
https://reviews.llvm.org/D149013
More information about the cfe-commits
mailing list