It segfaults inside std::variant::emplace because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547. However, a workaround of that libstdc++'s bug may be added in GSL. Say if the gsl::not_null<int*> class had a noexcept move constructor, an optimized path without the bug could be chosen.
I suppose it is worth highlighting a lack of interoperability between gsl::not_null and std::variant from libstdc++. Consider this code.
https://godbolt.org/z/KTP9EdMzf → run the code above in the playground
It segfaults inside std::variant::emplace because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547. However, a workaround of that libstdc++'s bug may be added in GSL. Say if the
gsl::not_null<int*>
class had a noexcept move constructor, an optimized path without the bug could be chosen.