[Bug c++/86646] Special member function 'cannot be defaulted' if type alias is used

2023-08-18 Thread arthur.j.odwyer at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86646

Arthur O'Dwyer  changed:

   What|Removed |Added

 CC||arthur.j.odwyer at gmail dot 
com

--- Comment #4 from Arthur O'Dwyer  ---
I just ran into this (it's one of the examples of vendor divergence in
P2953R0).
https://isocpp.org/files/papers/P2953R0.html#corner-cases

  // https://godbolt.org/z/sxv5rvn8o
  template
  struct C {
C& operator=(std::add_lvalue_reference_t) = default;
  };
  C cl;

GCC 13 says:

error: 'C<  >& C< 
>::operator=(std::add_lvalue_reference_t >
>)' cannot be defaulted
5 |   C& operator=(std::add_lvalue_reference_t) = default;
  |^~~

I confirm Andrew's observation that Clang is the odd one out in accepting this
code (GCC, MSVC, EDG all reject). But it also seems pretty obvious that it
should be accepted. Brian Bi concurs: "I couldn't figure out any reason why
this shouldn't be valid."

Or again something like this:

  template
  struct C {
C(std::conditional_t) = default;
C(std::conditional_t);
  };
  static_assert(std::is_trivially_copy_constructible_v>);
  static_assert(std::is_trivially_move_constructible_v>);

GCC+EDG+MSVC reject; Clang accepts; and I think Clang is the conforming one.

A related situation is

  // https://godbolt.org/z/1bhEx1Gr1
  template
  struct C {
template using A = const C&;
C(A...) = default;
  // this is a default ctor or a copy ctor, depending on sizeof...(Ts)
  };
  static_assert(std::is_trivially_constructible_v>);
  static_assert(std::is_trivially_copy_constructible_v>);

GCC rejects; Clang+EDG+MSVC accept; and I think Clang+EDG+MSVC are conforming.

[Bug c++/86646] Special member function 'cannot be defaulted' if type alias is used

2021-12-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86646

--- Comment #3 from Andrew Pinski  ---
MSVC also rejects it for the same reason as GCC (and ICC). Which makes clang
the one which is different than all others.

[Bug c++/86646] Special member function 'cannot be defaulted' if type alias is used

2018-07-24 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86646

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
We reject the code because defaultable_fn_check doesn't like the copy ctor: it
asks copy_fn_p whether it is a copy ctor but it doesn't think so:
12997   else if (TYPE_REF_P (arg_type)
12998&& !TYPE_REF_IS_RVALUE (arg_type)
12999&& TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) == DECL_CONTEXT
(d))
here both the main variant and the context are "struct Foo", but they compare
unequal.

Will poke some more at this.

[Bug c++/86646] Special member function 'cannot be defaulted' if type alias is used

2018-07-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86646

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-23
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
ICC rejects it for the same reason, but I don't see any justification for that
in the standard.

Clang accepts it.