[Bug c++/92856] incorrectly accepts invalid C++11 braced initialisation of double from long double
marc at kdab dot com
gcc-bugzilla@gcc.gnu.org
Mon Dec 9 10:28:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92856
--- Comment #3 from Marc Mutz <marc at kdab dot com> ---
Indeed, I didn't check that it actually fails in SFINAE. Sorry for that.
This works:
// https://godbolt.org/z/EfJmS4
#include <utility>
#include <experimental/type_traits>
template <typename From, typename To>
using nonnarrowing_test = decltype(To{std::declval<From&>()});
template <typename From, typename To>
using is_narrowing =
std::negation<std::experimental::is_detected<nonnarrowing_test, From, To>>;
static_assert(is_narrowing<long double, double>{});
static_assert(!is_narrowing<double, long double>{});
More information about the Gcc-bugs
mailing list