https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057

--- Comment #2 from pj at patrickjohnston dot org ---
Initialising a `variant<double>` from an `int` should not be an error due to
p0608. Compared to before, p0608 only requires that `double x[] = {600};` is
well formed. See https://wandbox.org/permlink/IHQ3NnuoNmQRr5a7

GCC info is:
Version 10.0.0 20190919
System type x86_64-pc-linux-gnu
GCC configuration options:
    --prefix=/opt/wandbox/gcc-head
    --enable-languages=c,c++
    --disable-multilib
    --without-ppl
    --without-cloog-ppl
    --enable-checking=release
    --disable-nls
    --enable-lto

Command line `g++ prog.cc -Wall -Wextra -std=c++17 -pedantic`

The compiler output is pretty large, here's the relevant bit:
    prog.cc: In function 'int main()':
    prog.cc:13:29: error: no matching function for call to
'std::variant<double>::variant(<brace-enclosed initializer list>)'
       13 |     std::variant<double>{600}; // Fails
          |                             ^
    In file included from prog.cc:1:

    [...]

    /opt/wandbox/gcc-head/include/c++/10.0.0/variant:1327:2: note: candidate:
'template<class _Tp, class, class, class _Tj, class> constexpr
std::variant<_Types>::variant(_Tp&&) [with _Tp = _Tp; <template-parameter-2-2>
= <template-parameter-1-2>; <template-parameter-2-3> =
<template-parameter-1-3>; _Tj = _Tj; <template-parameter-2-5> =
<template-parameter-1-5>; _Types = {double}]'
     1327 |  variant(_Tp&& __t)
          |  ^~~~~~~
    /opt/wandbox/gcc-head/include/c++/10.0.0/variant:1327:2: note:   template
argument deduction/substitution failed:
    /opt/wandbox/gcc-head/include/c++/10.0.0/variant: In substitution of
'template<class ... _Types> template<class _Tp, class> using __accepted_type =
std::variant<_Types>::__to_type<__accepted_index<_Tp> > [with _Tp = int&&;
<template-parameter-2-2> = std::enable_if<true, void>::type; _Types =
{double}]':
    /opt/wandbox/gcc-head/include/c++/10.0.0/variant:1323:9:   required from
here
    /opt/wandbox/gcc-head/include/c++/10.0.0/variant:1293:8: error: no type
named 'type' in 'struct std::enable_if<false, void>'
     1293 |  using __accepted_type = __to_type<__accepted_index<_Tp>>;
          |        ^~~~~~~~~~~~~~~

Reply via email to