[Bug c++/80691] Narrowing conversion in {} allowed in a SFINAE context
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 9 15:39:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80691
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-05-09
Ever confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This only happens in C++17 mode. With -std=gnu++14 it compiles OK, and also
with -std=c++14 if you make it C++14-compatible:
#include <utility>
#include <type_traits>
template<typename...> using void_t = void;
template<typename T, typename U, typename = void>
struct is_nonnarrowing_conversion : std::false_type {};
template<typename T, typename U>
struct is_nonnarrowing_conversion<T, U,
void_t<decltype(T{ std::declval<U>() })>> : std::true_type {};
template<typename T>
class wrapper
{
public:
wrapper(T) {}
};
static_assert(!is_nonnarrowing_conversion<int, float>(), "");
static_assert(!is_nonnarrowing_conversion<wrapper<int>, float>(), "");
More information about the Gcc-bugs
mailing list