[clang] 0de12bb - [clang][bytecode] Only block pointers can be partially initialized (#160075)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 23 02:22:31 PDT 2025


Author: Timm Baeder
Date: 2025-09-23T11:22:27+02:00
New Revision: 0de12bb4e1dee74452b66419c624665995e1ad69

URL: https://github.com/llvm/llvm-project/commit/0de12bb4e1dee74452b66419c624665995e1ad69
DIFF: https://github.com/llvm/llvm-project/commit/0de12bb4e1dee74452b66419c624665995e1ad69.diff

LOG: [clang][bytecode] Only block pointers can be partially initialized (#160075)

So ignore the rest in `checkFullyInitialized()`.

Fixes #160071

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/EvaluationResult.cpp
    clang/test/AST/ByteCode/typeid.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp
index ba818788d7026..7c3c21cf28251 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.cpp
+++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp
@@ -133,6 +133,8 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S,
 
   if (Ptr.isZero())
     return true;
+  if (!Ptr.isBlockPointer())
+    return true;
 
   // We can't inspect dead pointers at all. Return true here so we can
   // diagnose them later.

diff  --git a/clang/test/AST/ByteCode/typeid.cpp b/clang/test/AST/ByteCode/typeid.cpp
index 179a66fd7fd0a..00b01c8e40682 100644
--- a/clang/test/AST/ByteCode/typeid.cpp
+++ b/clang/test/AST/ByteCode/typeid.cpp
@@ -32,10 +32,10 @@ static_assert(&typeid(int) < &typeid(long)); // both-error {{not an integral con
 static_assert(&typeid(int) > &typeid(long)); // both-error {{not an integral constant expression}} \
                                              // both-note {{comparison between pointers to unrelated objects '&typeid(int)' and '&typeid(long)' has unspecified value}}
 
- struct Base {
-   virtual void func() ;
- };
- struct Derived : Base {};
+struct Base {
+ virtual void func() ;
+};
+struct Derived : Base {};
 
 constexpr bool test() {
   Derived derived;
@@ -52,3 +52,10 @@ int dontcrash() {
   );
   return pti.__flags == 0 ? 1 : 0;
 }
+
+namespace TypeidPtrInEvaluationResult {
+  struct C {};
+  C c = C();
+  consteval const std::type_info *ftype_info() { return &typeid(c); }
+  const std::type_info *T1 = ftype_info();
+}


        


More information about the cfe-commits mailing list