`make_opaque_handle()` causes compiler to segfault when defining constexpr local shorthand for local class"s `noexcept`s: `is_nothrow`

Fortune for opaque_handle's current commit: Future small blessing − 末小吉
master
Avril 2 years ago
parent 70d92c60b1
commit 742aa072ec
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -210,7 +210,7 @@ concept OpaqueHandleFunc = std::is_invocable_v<F, T*, opaque_handle_operation>
template<typename T, OpaqueHandleFunc<T> HandleF> // Note: This should be a lambda, or a free-function. it's lifetime must not end before the `opaque_handle` returned from this function does.
constexpr inline opaque_handle make_opaque_handle(T* data, const HandleF& handler) noexcept
{
constexpr bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>;
constexpr const bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>;
struct object_handler
{
@ -242,8 +242,8 @@ constexpr inline opaque_handle make_opaque_handle(T* data, const HandleF& handle
template<typename T, OpaqueHandleFunc<T> HandleF>
constexpr inline opaque_handle make_opaque_handle(T* data, HandleF&& handler) noexcept(std::is_nothrow_move_constructible_v<HandleF>)
{
constexpr bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>;
constexpr bool is_nothrow_ctor = std::is_nothrow_move_constructible_v<HandleF>;
constexpr const bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>;
constexpr const bool is_nothrow_ctor = std::is_nothrow_move_constructible_v<HandleF>;
struct object_handler
{

@ -27,9 +27,25 @@ static inline void print(const std::string& string)
return print_view(sv);
}
void use_moh()
{
std::string str{"Hello from 2!"};
opaque_handle v{make_opaque_handle<std::string>(&str, [](std::string* ptr, auto op) noexcept {
if(ptr) {
switch(op) {
case opaque_handle_operation::Clone: return new std::string(*ptr);
case opaque_handle_operation::Delete: delete ptr; break;
}
}
return static_cast<std::string*>(nullptr);
})};
print(*v);
}
int main()
{
const opaque_handle v{make_opaque_object_handle(std::string{"Hello world"})};
print(*v); //XXX: Why does converting it to string_view here break it?
use_moh();
return 0;
}

Loading…
Cancel
Save