Author: Timm Baeder Date: 2026-04-12T14:30:49+02:00 New Revision: de56830e67700cac9b8b028a86d077b24847d251
URL: https://github.com/llvm/llvm-project/commit/de56830e67700cac9b8b028a86d077b24847d251 DIFF: https://github.com/llvm/llvm-project/commit/de56830e67700cac9b8b028a86d077b24847d251.diff LOG: [clang][bytecode] Handle zero pointers in `isConstexprUnknown()` (#191691) Added: Modified: clang/lib/AST/ByteCode/Interp.cpp clang/test/AST/ByteCode/cxx17.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 8cc3c9216f7f4..0a5270bef2b82 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -266,7 +266,7 @@ bool isConstexprUnknown(const Block *B) { } bool isConstexprUnknown(const Pointer &P) { - if (!P.isBlockPointer()) + if (!P.isBlockPointer() || P.isZero()) return false; return isConstexprUnknown(P.block()); } diff --git a/clang/test/AST/ByteCode/cxx17.cpp b/clang/test/AST/ByteCode/cxx17.cpp index 0cf3a4f666d63..583d9879ad245 100644 --- a/clang/test/AST/ByteCode/cxx17.cpp +++ b/clang/test/AST/ByteCode/cxx17.cpp @@ -149,3 +149,29 @@ namespace NonConstexprStructuredBinding { static_assert(&a != &b); } } + + + + +int d, m; +struct C { + constexpr C() {} + constexpr C(const C &) {} + template <int I> int &get() const { + // static_assert(d == 1 + I); + ++d; + return m; + } +}; + +template <> struct std::tuple_size<const C> { + static const int value = 3; +}; +template <int I> struct std::tuple_element<I, const C> { + using type = int; +}; + +namespace ZeroInCheckInvoke { + constexpr C foo(const C &) { return C{}; } + thread_local const auto &[s, t, u] = foo(C{}); // both-warning {{thread_local}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
