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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|std::variant default        |[9/10/11 Regression]
                   |constructor                 |std::variant default
                   |                            |constructor
   Last reconfirmed|                            |2020-08-17
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.2.0, 11.0, 9.3.0
          Component|libstdc++                   |c++
      Known to work|                            |8.4.0
                 CC|                            |jason at gcc dot gnu.org
           Keywords|                            |rejects-valid

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is not a bug in std::variant:


template<bool B>
struct bool_constant
{
  static constexpr bool value = B;
  using type = bool_constant;
};

using true_type = bool_constant<true>;

template<typename T>
struct is_default_constructible
: bool_constant<__is_constructible(T)>
{ };

void testVarStruct()
{
    struct DataWithStruct {
        struct A {
            int number = 5; // compiles, if remove initialization
        };

        is_default_constructible<A>::type t = true_type{};
    };
}

v.C: In function 'void testVarStruct()':
v.C:22:47: error: could not convert 'true_type{}' from 'bool_constant<true>' to
'bool_constant<false>'
   22 |         is_default_constructible<A>::type t = true_type{};
      |                                               ^~~~~~~~~~~
      |                                               |
      |                                               bool_constant<true>


This stopped working with r269032 which changed the result of the
__is_constructible built-in.

Clang also rejects this, for the same reason, but EDG accepts it.

Reply via email to