[clang] dead8f8 - [clang][Interp] Pointers into unknown-size arrays are never one-past-end
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 26 07:12:30 PDT 2024
Author: Timm Bäder
Date: 2024-06-26T16:12:13+02:00
New Revision: dead8f845f2549db5dec16b59b80d3e321948674
URL: https://github.com/llvm/llvm-project/commit/dead8f845f2549db5dec16b59b80d3e321948674
DIFF: https://github.com/llvm/llvm-project/commit/dead8f845f2549db5dec16b59b80d3e321948674.diff
LOG: [clang][Interp] Pointers into unknown-size arrays are never one-past-end
Added:
Modified:
clang/lib/AST/Interp/Pointer.h
clang/test/AST/Interp/arrays.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index 0cd26ecf73f24..5faec75cc3ec5 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -553,6 +553,9 @@ class Pointer {
if (!asBlockPointer().Pointee)
return false;
+ if (isUnknownSizeArray())
+ return false;
+
return isElementPastEnd() ||
(getSize() == getOffset() && !isZeroSizeArray());
}
diff --git a/clang/test/AST/Interp/arrays.cpp b/clang/test/AST/Interp/arrays.cpp
index 7d231d3759421..26ec39e9cca65 100644
--- a/clang/test/AST/Interp/arrays.cpp
+++ b/clang/test/AST/Interp/arrays.cpp
@@ -626,3 +626,4 @@ constexpr int *get2() {
extern int same_entity_2[];
return same_entity_2;
}
+static_assert(get2() == same_entity_2, "failed to find previous decl");
More information about the cfe-commits
mailing list