[Bug c++/106485] Can't use heap pointer in `static_assert`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485 Andrew Pinski changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #4 from Andrew Pinski --- Oh wait there comment #0 is still invalid (undefined?) code: ``` struct I { int* i = new int{1}; constexpr ~I() { delete i; } }; static_assert([] ()consteval { return I{}.i != 0; }()); ``` Works just fine. So yes this again is the same issue of static_assert not being immediate function context.
[Bug c++/106485] Can't use heap pointer in `static_assert`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485 Andrew Pinski changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed||2023-01-19 --- Comment #3 from Andrew Pinski --- I think comment #0 is a different issue from comment #2 really. comment #0 has a temporary while comment #2 has an consteval. Also GCC accepts this just fine though: #include static_assert(!std::string{"abcdegf"}.empty());
[Bug c++/106485] Can't use heap pointer in `static_assert`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485 --- Comment #2 from Johel Ernesto Guerrero Peña --- I think that's different. Actually, I think it's Clang that's wrong. As mentioned at https://cpplang.slack.com/archives/C21PKDHSL/p1656857369259539?thread_ts=1656856509.892079&cid=C21PKDHSL: > The expression of the `static_assert` is not an > [immediate function > context](https://eel.is/c++draft/expr.const#def:immediate_function_context). > Wrapping it in `[]() consteval { return s().empty(); }()` > [works](https://godbolt.org/z/PKTE7zofW), > whereas removing that `consteval` causes Clang to also complain. See https://godbolt.org/z/4GMxo13vv. ```C++ #include consteval auto s() { return std::string(); } static_assert(s().empty()); // Only Clang accepts. // static_assert([]() consteval { return s().empty(); }()); // All accept. // static_assert([]() { return s().empty(); }()); // All reject. ``` Opened https://github.com/llvm/llvm-project/issues/57627 for that.
[Bug c++/106485] Can't use heap pointer in `static_assert`
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=105826 --- Comment #1 from Andrew Pinski --- I think this is a dup of bug 105826.