Skip to content

Commit 761fb14

Browse files
tbaederrAlexisPerry
authored andcommitted
[clang][Interp] Fix returning primitive non-blockpointers
We can't deref() them, so return false here.
1 parent f38b2cb commit 761fb14

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/AST/Interp/Pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ std::optional<APValue> Pointer::toRValue(const Context &Ctx) const {
347347
Ty = AT->getValueType();
348348

349349
// Invalid pointers.
350-
if (Ptr.isDummy() || !Ptr.isLive() ||
350+
if (Ptr.isDummy() || !Ptr.isLive() || !Ptr.isBlockPointer() ||
351351
(!Ptr.isUnknownSizeArray() && Ptr.isOnePastEnd()))
352352
return false;
353353

clang/test/AST/Interp/literals.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ constexpr int Failed2 = Failed1 + 1; // both-error {{must be initialized by a co
4545
static_assert(Failed2 == 0, ""); // both-error {{not an integral constant expression}} \
4646
// both-note {{initializer of 'Failed2' is not a constant expression}}
4747

48+
const int x = *(volatile int*)0x1234;
49+
4850
namespace ScalarTypes {
4951
constexpr int ScalarInitInt = int();
5052
static_assert(ScalarInitInt == 0, "");

0 commit comments

Comments
 (0)