[PATCH] D154928: [clang][Interp] Call dtor or Floating values
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 11 01:12:53 PDT 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The APFloat might heap-allocate some memory, so we need to call its
destructor.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154928
Files:
clang/lib/AST/Interp/Descriptor.cpp
clang/test/AST/Interp/floats.cpp
Index: clang/test/AST/Interp/floats.cpp
===================================================================
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -137,3 +137,7 @@
constexpr A<double> b{12};
static_assert(a.f == 0.0, "");
};
+
+namespace LongDouble {
+ constexpr long double ld = 3.1425926539;
+}
Index: clang/lib/AST/Interp/Descriptor.cpp
===================================================================
--- clang/lib/AST/Interp/Descriptor.cpp
+++ clang/lib/AST/Interp/Descriptor.cpp
@@ -189,6 +189,11 @@
}
static BlockDtorFn getDtorPrim(PrimType Type) {
+ // Floating types are special. They are primitives, but need their
+ // destructor called, since they might allocate memory.
+ if (Type == PT_Float)
+ return dtorTy<PrimConv<PT_Float>::T>;
+
COMPOSITE_TYPE_SWITCH(Type, return dtorTy<T>, return nullptr);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154928.538954.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230711/d5ec0319/attachment.bin>
More information about the cfe-commits
mailing list