[clang] [clang][bytecode] Only block pointers can be partially initialized (PR #160075)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 22 04:25:31 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160075
So ignore the rest in `checkFullyInitialized()`.
Fixes #160071
>From a955773e97e1b24bdccc8703ebd3bfa3e91f37e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 22 Sep 2025 13:24:18 +0200
Subject: [PATCH] [clang][bytecode] Only block pointers can be partially
initialized
So ignore the rest in `checkFullyInitialized()`.
Fixes #160071
---
clang/lib/AST/ByteCode/EvaluationResult.cpp | 2 ++
clang/test/AST/ByteCode/typeid.cpp | 15 +++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
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