Created on 2014-07-01.00:00:00 last changed 40 months ago
Proposed resolution:
This wording is relative to N4892.
Add the following paragraph to [reentrancy]:
-?- During the execution of a standard library non-static member function F on an object, if that object is accessed through a glvalue that is not obtained, directly or indirectly, from the this pointer of F, in a manner that can conflict ([intro.races]) with any access that F is permitted to perform ([res.on.data.races]), the behavior is undefined unless otherwise specified.
[ 2021-07-29 Tim suggests new wording ]
The "this pointer" restriction is modeled on [class.cdtor] p2. It allows us to continue to specify a member function f as calling some other member function g, since any such call would use something obtained from the first member function's this pointer.
In all other cases, this wording disallows such "recursion on object" unless both member functions are const (or are treated as such for the purposes of data race avoidance). Using "access" means that we also cover direct access to the object representation, such as the following pathological example from Arthur O'Dwyer, which is now undefined:std::string s = "hello world"; char *first = (char*)&s; char *last = (char*)(&s + 1); s.append(first, last);
[ 2016-05 email from STL ]
I don't have any better suggestions than my original PR at the moment.
Previous resolution [SUPERSEDED]:
This wording is relative to N3936.
Change [reentrancy] p1 as indicated:
-1- Except where explicitly specified in this standard, it is implementation-defined which functions (including different member functions called on a single object) in the Standard C++ library may be recursively reentered.
[ 2015-07 Telecon Urbana ]
Marshall to ping STL for updated wording.
[ 2014-11-03 Urbana ]
AJM confirmed with SG1 that they had no special concerns with this issue, and LWG should retain ownership.
AM: this is too overly broad as it also covers calling the exact same member function on a different objectMove to Open
N3936 [reentrancy]/1 talks about "functions", but that doesn't address the scenario of calling different member functions of a single object. Member functions often have to violate and then re-establish invariants. For example, vectors often have "holes" during insertion, and element constructors/destructors/etc. shouldn't be allowed to observe the vector while it's in this invariant-violating state. The [reentrancy] Standardese should be extended to cover member functions, so that implementers can either say that member function reentrancy is universally prohibited, or selectively allowed for very specific scenarios.
(For clarity, this issue has been split off from LWG 2382.)History | |||
---|---|---|---|
Date | User | Action | Args |
2021-07-30 02:16:19 | admin | set | messages: + msg11978 |
2017-11-05 05:11:26 | admin | set | messages: + msg9505 |
2015-09-27 20:55:06 | admin | set | messages: + msg7553 |
2014-11-08 18:05:15 | admin | set | status: new -> open |
2014-11-08 18:01:47 | admin | set | status: open -> new |
2014-11-08 16:43:57 | admin | set | messages: + msg7176 |
2014-11-08 16:43:57 | admin | set | status: new -> open |
2014-07-02 20:30:26 | admin | set | messages: + msg7090 |
2014-07-01 00:00:00 | admin | create |