Clang9 warning and compiler error with atomics

You described the behavior of trivilly copyable types. If we don’t call the constructor/destructor, we may break something in the inner type data, if the constructor/destructor requires some additional actions.
We don’t need default constructor, we need defaulted drfault constructor, no copy/move operators and defaulted destructor.

The runtime at first allocates memory for the mapped data (here we need to call default constructor to initialize the data),

Why would we need to call the default constructor here? If the data is not mapped to / tofrom, the “value of the corresponding list item is undefined” (OpenMP 5.0, p318).

then bitcopies the data from mapped data to the buffer (need to call copy operator)

If the runtime does copy the data, these two steps together are equivalent to a single invocation of the copy-constructor, aren’t they?

Jonas

Best regards,
Alexey Bataev

6 дек. 2019 г., в 08:24, Jonas Hahnfeld via Openmp-dev openmp-dev@lists.llvm.org написал(а):

You described the behavior of trivilly copyable types. If we don’t call the constructor/destructor, we may break something in the inner type data, if the constructor/destructor requires some additional actions.
We don’t need default constructor, we need defaulted drfault constructor, no copy/move operators and defaulted destructor.

The runtime at first allocates memory for the mapped data (here we need to call default constructor to initialize the data),

Why would we need to call the default constructor here? If the data is not mapped to / tofrom, the “value of the corresponding list item is undefined” (OpenMP 5.0, p318).

That’s why we have just a warning to notify the user that there might be some problems.

then bitcopies the data from mapped data to the buffer (need to call copy operator)

If the runtime does copy the data, these two steps together are equivalent to a single invocation of the copy-constructor, aren’t they?

Generally speaking, no. Default constructor + assignment operator may lead to a different result than just copy constructor (there can be different functionality). The runtime implements it in the way of default constructor (mem alloc) + copy assignment (memcpy).