From e8813d52ebb17c37e6f120c2bd2da2971a9e6257 Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 12 Mar 2022 16:55:32 +0000 Subject: [PATCH] All `make_opaque_handle()` functions cause compiler segfault at `constexpr bool is_nothrow`; they should be changed to #define macros. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for opaque_handle's current commit: Future blessing − 末吉 --- include/opaque.hh | 5 +++-- src/main.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/opaque.hh b/include/opaque.hh index 5c868fe..fd5460e 100644 --- a/include/opaque.hh +++ b/include/opaque.hh @@ -203,6 +203,7 @@ template concept OpaqueHandleFunc = std::is_invocable_v && std::is_convertible_v, T*>; +//TODO: Turn all local `constexpr is_nothrow` in the following functions into #define macros. The constexpr locals being used in a local class cause the compiler to segfault for some reason... /// Create and opaque_handle from a data pointer and a lambda which handles the copying (if possible) and deleting of the object /// @@ -242,8 +243,8 @@ constexpr inline opaque_handle make_opaque_handle(T* data, const HandleF& handle template HandleF> constexpr inline opaque_handle make_opaque_handle(T* data, HandleF&& handler) noexcept(std::is_nothrow_move_constructible_v) { - constexpr const bool is_nothrow = std::is_nothrow_invocable_v; - constexpr const bool is_nothrow_ctor = std::is_nothrow_move_constructible_v; + constexpr bool is_nothrow = std::is_nothrow_invocable_v; //XXX: Causes segfault... TODO: turn these into a #define macro + constexpr bool is_nothrow_ctor = std::is_nothrow_move_constructible_v; struct object_handler { diff --git a/src/main.cpp b/src/main.cpp index ba07755..d514d9e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,7 @@ static inline void print(const std::string& string) void use_moh() { std::string str{"Hello from 2!"}; - opaque_handle v{make_opaque_handle(&str, [](std::string* ptr, auto op) noexcept { + constexpr auto _h = [](std::string* ptr, auto op) noexcept { if(ptr) { switch(op) { case opaque_handle_operation::Clone: return new std::string(*ptr); @@ -38,7 +38,8 @@ void use_moh() } } return static_cast(nullptr); - })}; + }; + opaque_handle v{make_opaque_handle(&str)}; print(*v); }