Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does "default copy constructible" mean? #210

Open
psalz opened this issue Jan 7, 2022 · 5 comments
Open

What does "default copy constructible" mean? #210

psalz opened this issue Jan 7, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@psalz
Copy link
Member

psalz commented Jan 7, 2022

Section 4.3.3 Common by-value semantics currently states that types such as id and range must be "default copy constructible", "default destructible", "default move constructible" and "default move assignable". What does that mean? As far as I can tell, these terms are not used anywhere on cppreference.

I assume the intent was to say trivially constructible/destructible/moveable. This would already be true for most implementations and types (hipSYCL does not fulfill all requirements for item, h_item and nd_range).

cc @AerialMantis I think you came up with this wording originally in 2e3b42c.

@AerialMantis
Copy link
Collaborator

Yes I think you're right, so the original intent of this wording was to require the types to use the implicit default constructor, move/copy constructors and destructor, so as I understand this would translate to is_trivially_default_constructible, is_trivially_copy_constructible, is_trivially_move_constructible and is_trivially_destructible, I think this would better describe the intent than the current wording.

@psalz
Copy link
Member Author

psalz commented Jan 11, 2022

As I understand it is_trivially_* is actually a stronger guarantee. For example a type struct foo { std::vector<int> bar; }; has an implicitly defaulted copy constructor, but is not trivially copy-constructible.

After looking some more into this I'm actually a bit confused:

Section 4.5.3 says special member functions should be defaulted. However, it also lists all of them in table 9 and says that classes must either follow the rule of zero or the rule of five. The latter implies that there can also be explicitly defined special member functions, which means they are no longer defaulted and classes are no longer trivially-copyable.

I'm pretty sure at least sycl::id and sycl::range are supposed to be device-copyable, right? Assuming they may follow the rule of five and are therefore not guaranteed to be trivially-copyable, they would have to be listed explicitly as device-copyable in section 3.13.1, which they are not.

@gmlueck
Copy link
Contributor

gmlueck commented Jan 11, 2022

I'm pretty sure at least sycl::id and sycl::range are supposed to be device-copyable, right?

I propose that we define these as trivially copyable in https://gitlab.khronos.org/sycl/Specification/-/issues/564

@fraggamuffin
Copy link

Linked to internal github issue on marray improvements

@fraggamuffin
Copy link

leaning towards changing it to trivially_#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants