[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 17 20:14:10 PDT 2025
================
@@ -572,3 +571,19 @@ namespace VectorCast {
#endif
}
#endif
+
+namespace ToPrimPtrs {
+ struct S { int foo () { return 0; } };
+ auto ptr = __builtin_bit_cast(int *, ((__INTPTR_TYPE__) 0));
+ auto nptr = __builtin_bit_cast(nullptr_t, ((__INTPTR_TYPE__)0));
+
+ constexpr auto cptr = __builtin_bit_cast(int *, ((__INTPTR_TYPE__) 0)); // both-error {{must be initialized by a constant expression}} \
+ // both-note {{bit_cast to a pointer type is not allowed in a constant expression}}
+ constexpr auto cnptr = __builtin_bit_cast(nullptr_t, ((__INTPTR_TYPE__)0));
+
+#if !defined(_WIN32)
----------------
tbaederr wrote:
Apparently member pointers have a different size on windows.
https://github.com/llvm/llvm-project/pull/158575
More information about the cfe-commits
mailing list