lundi 23 juillet 2018

Explicitly defaulted special member functions with aliased type — Clang vs. GCC

GCC trunk (9.0) and Clang trunk (7.0) disagree on the following code:

template<int size_>
struct BadArray {
    static constexpr int size = size_;// GCC complains due to this indirection
    using Self = BadArray<size>;

    Self& operator=(const Self&) noexcept = default;
};

Compilation with GCC fails with the error message

error: 'BadArray<size_>::Self& BadArray<size_>::operator=(const Self&)' cannot be defaulted

while Clang accepts the code (live example with GCC 8.1 and Clang 6.0).

  1. Is there a well-defined behavior? If yes, which compiler is right?
  2. Is it appropriate to file a bug report for either GCC or Clang?

Aucun commentaire:

Enregistrer un commentaire