A user-defined ctor should be non-trivial.
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
There are a bunch of recent commits (between 9 months and 2 years) that rely on an apparent nvcc quirk that treats empty default ctors as trivial ctors, whereas in the standard, they are non-trivial.
These lines break consistent enforcement of a prohibition against dynamic initializers on `__device__` and `__shared__` objects.
A simple example is this:
https://github.com/NVIDIA/thrust/blob/main/thrust/system/detail/sequential/execution_policy.h#L68
`tag` has a non-trivial ctor at line 52. That should make the `__device__` object declaration at 68 ill-formed. However nvcc accepts it, because the ctor has an empty definition.
The more complex case is the set of placeholders starting here:
https://github.com/NVIDIA/thrust/blame/main/thrust/functional.h#L1656
These were all added to support nvc++, but are certainly non-conformant.
https://github.com/NVIDIA/thrust/blame/main/thrust/detail/functional/actor.inl#L41
This default ctor even has a subobject initializer `eval_type`. When used from the placeholder `__device__` declarations, the `eval_type` is a specialization of the indexed `argumuent` here:
https://github.com/NVIDIA/thrust/blob/main/thrust/detail/functional/argument.h#L61
And the default ctor of `argument` also has an empty ctor, which nvcc treats as trivial for the purpose of device/shared object initialization.
Instead of recursively abusing this nvcc quirk, can those default ctors be defaulted, so that they're actually trivial, and then everything else would work in the standard way? It's taking me some effort to emulate nvcc's non-standard behavior.
Contributor guide
Research direction
Start with thrust/system/detail/sequential/execution_policy.h around the device declaration, then inspect the placeholder constructors in thrust/functional.h, thrust/detail/functional/actor.inl, and thrust/detail/functional/argument.h. Compare their current empty definitions and initializers with the standard’s triviality rules and nvcc behavior. Done means the affected device/shared declarations follow standard constructor triviality without relying on nvcc’s quirk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100