Skip to content

unique_span assignement operator bug with C++20. #660

@raplonu

Description

@raplonu

Hi,

I notice that cuda::unique_span does not compile with C++20 (and I suppose it is also the case with older standards too)

The issue comes from the move assignment operator:

unique_span& operator=(unique_span&& other) noexcept
{
	span_type released = other.release();
	if (data() != nullptr) {
		deleter_type{}(data());
	}
	data() = released.data();
	size() = released.size();
}

std::span data & size returns values, not references thus it is not possible to reassign them. I think what you did in the destructor is the correct approach.

unique_span& operator=(unique_span&& other) noexcept
{
	span_type released = other.release();
	if (data() != nullptr) {
		deleter_type{}(data());
	}
	static_cast<span_type&>(*this) = released;
}

Thanks a lot for all the efforts you put in this project.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions