Title
Pointer arithmetic in array-like containers
Status
drafting
Section
7.6.6 [expr.add]
Submitter
Jonathan Wakely

Created on 2015-10-20.00:00:00 last changed 95 months ago

Messages

Date: 2016-02-15.00:00:00

Notes from the February, 2016 meeting:

This issue is expected to be resolved by the resolution of issue 1776. The major problem is when the elements of the vector contain constant or reference members; 6.7.4 [basic.life] paragraph 7 implies that pointer arithmetic leading to such an object produces undefined behavior, and CWG expects this to continue. Some changes to the interface of std::vector may be required, perhaps using std::launder as part of iterator processing.

Date: 2015-10-20.00:00:00

The current direction for issue 1776 (see paper P0137) calls into question the validity of doing pointer arithmetic to address separately-allocated but contiguous objects in a container like std::vector. A related question is whether there should be some allowance made for allowing pointer arithmetic using a pointer to a base class if the derived class is a standard-layout class with no non-static data members. It is possible that std::launder could play a part in the resolution of this issue.

History
Date User Action Args
2017-02-06 00:00:00adminsetmessages: + msg5752
2017-02-06 00:00:00adminsetstatus: open -> drafting
2015-10-20 00:00:00admincreate