llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/140047.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+2) 
- (modified) clang/test/AST/ByteCode/cxx20.cpp (+8) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index fbe04fe3231dd..74efc3c914504 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1375,6 +1375,8 @@ bool CheckDestructor(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
     return false;
   if (!CheckTemporary(S, OpPC, Ptr, AK_Destroy))
     return false;
+  if (!CheckRange(S, OpPC, Ptr, AK_Destroy))
+    return false;
 
   // Can't call a dtor on a global variable.
   if (Ptr.block()->isStatic()) {
diff --git a/clang/test/AST/ByteCode/cxx20.cpp 
b/clang/test/AST/ByteCode/cxx20.cpp
index 5f62a5648bab7..0b2234ef83298 100644
--- a/clang/test/AST/ByteCode/cxx20.cpp
+++ b/clang/test/AST/ByteCode/cxx20.cpp
@@ -1007,3 +1007,11 @@ namespace TempDtor {
     a_ref.~A(); // both-note {{destruction of temporary is not allowed in a 
constant expression outside the expression that created the temporary}}
   }
 }
+
+namespace OnePastEndDtor {
+  struct A {int n; };
+  constexpr void destroy_past_end() { // both-error {{never produces a 
constant expression}}
+    A a;
+    (&a+1)->~A(); // both-note {{destruction of dereferenced one-past-the-end 
pointer}}
+  }
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/140047
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to