Skip to content

error when define a move assignment = default (if using type alias) #56456

@twinstar6980

Description

@twinstar6980

For some reason, I used a type alias when defining the move constructor, which compiles successfully on MSVC and GCC, but Clang doesn't allow it
I tested other special member functions, copy constructor, move constructor, copy assignment function can all use the = default declaration explicitly in the case of using type alias, only move assignment function does not allow this, but it can use = delete explicitly, so is this a bug?
here is my test code

// constant reference
template <typename T>
using RC = T const &;

// non-constant reference
template <typename T>
using RV = T &;

// r-value reference
template <typename T>
using RM = T&&;

struct A {

	// default constructor
	A () = default;
	// copy constructor
	A (RC<A>) = default;
	// move constructor
	A (RM<A>) = default;
	
	// copy assignment
	auto operator = (RC<A>) -> RV<A> = default;
	// move assignment
	auto operator = (RM<A>) -> RV<A> = default; // error: only special member functions may be defaulted
	//auto operator = (RM<A>) -> RV<A> = delete;  // OK
	
};

int main () {
	return 0;
}

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions