Title
29.5 should state that atomic types are not trivially copyable
Status
resolved
Section
[atomics.types.generic]
Submitter
Jens Maurer

Created on 2014-08-14.00:00:00 last changed 87 months ago

Messages

Date: 2017-02-02.00:00:00

[ 2017-02-02 Daniel comments and adjusts status ]

The NAD resolution is inappropriate, because the group didn't argue against the actual issue, instead the situation was that core wording changes in an unrelated area had resolved the previous problem indirectly. In this cases the correct resolution is Resolved by core wording changes as described by Jens Maurer in the 2017-01-19 comment.

Date: 2017-01-27.00:00:00

[ 2017-01-27 Telecon ]

Resolved as NAD.

Date: 2017-01-19.00:00:00

[ 2017-01-19 Jens Maurer comments, issue state to Review ]

The previous entry "[2016-03 Jacksonville] This was resolved by Core Issue 1496" is wrong; Core issue 1496 only modified the definition of "trivial class", not of "trivially copyable". However, as Ville Voutilainen observed, Core Issue 1734 made all atomics not trivially copyable, because they do not have at least one non-deleted copy/move constructor or copy/move assignment operator.

Previous resolution [SUPERSEDED]:

  1. Change [atomics.types.generic]p3 as indicated:

    Specializations and instantiations of the atomic template shall have a deleted copy constructor, a deleted copy assignment operator, and a constexpr value constructor. They are not trivially copyable types ([basic.types]).

Date: 2016-08-02.17:19:11

[ 2016-03 Jacksonville ]

This was resolved by Core Issue 1496

Date: 2016-03-07.06:00:57

[ 2016-03 Jacksonville ]

We think there is something coming from Core to resolve that, and that this will be NAD.
Until then, defer.

Date: 2015-09-11.00:00:00

[ 2015-09-11 Telecon ]

Howard: currently std::is_trivially_copyable<std::atomic> is true, so this resolution would contradict reality

Jonathan: changing that is good, we don't want it to be trivially copyable, otherwise users can memcpy them, which we really don't want

Howard: is it reasonable to memcpy something that isn't trivially copy constructible or trivially assignable?

Jonathan: no, it's not, but Core says you can, so this resolution is needed to stop people memcpying atomic

Howard: we should fix the core rule

Marshall: there is a separate issue of whether trivially-copyable makes sense, but this resolution is a net good purely because it stops memcpy of atomics

Howard: so should implementations specialize is_trivially_copyable the trait to meet this?

Jonathan: or add an empty, user-defined destructor.

Howard: should the spec specify that then?

Over-specification.

Howard: without that I fear implementation divergence.

Ville and Jonathan to investigate potential implementation options.

Ville: request a note on the issue saying we need review other types such as condition_variable to see if they are also unintentionally trivially-copyable. N4460 mentions some such types.

Date: 2015-05-05.00:00:00

[ 2015-05-05 Lenexa ]

Marshall: This was discussed on the telecon. Alisdair was going to write something to Mike and send it to Core.

Hwrd: Core says that deleted copies are trivially copyable, which makes no sense to Library people.

STL: There doesn't appear to be a Core issue about it.

Date: 2015-05-08.04:24:55

[ 2015-05 Lenexa, SG1 response ]

SG1 is fine with P/R (and agrees it's needed), but LWG may want to check the details; it's not entirely an SG1 issue.

Date: 2015-03-15.00:00:00

[ 2015-03-22, Jens Maurer responses to Cologne discussion ]

A library implementation could provide a partial specialization for is_trivially_copyable<atomic<T>>, to ensure that any such type query would return false.

Assuming such a specialization would be provided, how could a conforming program observe that per language rules an atomic specialization would actually be trivially copyable if there is no way to call the (deleted) copy constructor or copy assignment operator?

The sole effect of the suggested addition of the constraining sentence is that it would make a user program non-conforming that attempts to invoke memcpy (and the like) on atomic types, since that would invoke undefined behaviour.

Date: 2015-03-22.18:18:12

[ 2015-02 Cologne ]

GR has a minor problem with the style of the wording. VV has major issues with implementability.

Date: 2014-11-24.13:56:51

[ 2014-11 Urbana ]

Lawrence:Definition of "trivially copyable" has been changing.

Doesn't hurt to add proposed change, even if the sentence is redundant

Move to Review.

Date: 2014-08-14.00:00:00

Otherwise, one could use memcpy to save and restore the value according to 3.9p2.

It seems the core language rules in [class]p6 with [class.copy]p12 (trivial copy constructor) etc. and [dcl.fct.def.default]p5 (user-provided) say that the atomic types are trivially copyable, which is bad. We shouldn't rely on future core changes in that area and simply say in the library section [atomics.types.generic] that these very special types are not trivially copyable.

History
Date User Action Args
2017-02-02 19:53:29adminsetstatus: nad -> resolved
2017-01-30 15:36:02adminsetmessages: + msg8815
2017-01-30 15:36:02adminsetstatus: review -> nad
2017-01-25 20:27:52adminsetmessages: + msg8790
2017-01-25 20:27:52adminsetstatus: resolved -> review
2016-08-02 17:19:11adminsetmessages: + msg8329
2016-08-02 17:19:11adminsetstatus: open -> resolved
2016-03-07 06:00:57adminsetmessages: + msg8013
2016-03-07 06:00:57adminsetstatus: review -> open
2015-09-14 22:28:14adminsetmessages: + msg7524
2015-05-22 19:58:39adminsetmessages: + msg7450
2015-05-08 04:24:55adminsetmessages: + msg7404
2015-03-23 18:08:25adminsetmessages: + msg7250
2015-03-22 18:18:12adminsetmessages: + msg7238
2014-11-24 13:56:51adminsetmessages: + msg7205
2014-11-24 13:56:51adminsetstatus: new -> review
2014-10-05 17:50:43adminsetmessages: + msg7110
2014-08-14 00:00:00admincreate