[clang] [clang][bytecode] Allocate IntegralAP and Floating types using an allocator (PR #144246)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 19 11:17:29 PDT 2025
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/144246 at github.com>
tbaederr wrote:
Can you try applying
```diff
diff --git i/clang/lib/AST/ByteCode/IntegralAP.h w/clang/lib/AST/ByteCode/IntegralAP.h
index 0280ea072ca9..4c1fb61e3e15 100644
--- i/clang/lib/AST/ByteCode/IntegralAP.h
+++ w/clang/lib/AST/ByteCode/IntegralAP.h
@@ -92,7 +92,10 @@ public:
// Constructors.
IntegralAP() = default;
- IntegralAP(unsigned BitWidth) : BitWidth(BitWidth) {}
+ IntegralAP(unsigned BitWidth) : Val(0), BitWidth(BitWidth) {
+ assert(singleWord());
+ Val = 0;
+ }
IntegralAP(uint64_t *Memory, unsigned BitWidth)
: Memory(Memory), BitWidth(BitWidth) {}
IntegralAP(const APInt &V) : BitWidth(V.getBitWidth()) {
```
(or the equivalent) and re-checking?
In the single-word case, we're not explicitly setting `Val` to `0` and since the `Memory` Pointer only partially overlaps with it, the resulting value is garbage.
(I with ubsan would catch reads from inactive union members but alas)
https://github.com/llvm/llvm-project/pull/144246
More information about the cfe-commits
mailing list