https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87431
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Tue Sep 25 14:59:16 2018 New Revision: 264574 URL: https://gcc.gnu.org/viewcvs?rev=264574&root=gcc&view=rev Log: PR libstdc++/87431 optimise valueless_by_exception() If a std::variant can never get into valueless state then we don't need to do a runtime check for a valid alternative. PR libstdc++/87431 * include/std/variant (_Variant_storage<true, _Types...>::_M_valid): Avoid runtime test when all alternatives are scalars and so cannot throw during initialization. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/variant