hanickadot wrote: I was also implementing this and run into an issue, so I looked into your implementation and you have exactly same issue as I do, following code will fail: ```c++ namespace std { template <typename T> consteval bool is_within_lifetime(const T * ptr) noexcept { return __builtin_is_within_lifetime(ptr); } }
constexpr bool test_union(int * i) { // <-- note the constexpr here return std::is_within_lifetime(i); } static_assert([] consteval { union { int i; char c; } u = {.i = 10}; return test_union(&u.i); }()); ``` with error: ``` ./builtin-is-within-lifetime-call.cpp:8:10: error: call to consteval function 'std::is_within_lifetime<int>' is not a constant expression 8 | return std::is_within_lifetime(i); | ^ ./builtin-is-within-lifetime-call.cpp:8:34: note: function parameter 'i' with unknown value cannot be used in a constant expression 8 | return std::is_within_lifetime(i); | ^ ./builtin-is-within-lifetime-call.cpp:7:33: note: declared here 7 | constexpr bool test_union(int * i) { // <-- note the constexpr here | ^ 1 error generated. ``` https://github.com/llvm/llvm-project/pull/91895 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits