-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[basic.life] p9 Does an expression happen-before itself? #584
Comments
We can't treat the new-expression as a whole here. CWG2721 should have clarified this. |
The issue here is that the text "before" and "after" in this subclause refer to "happen-before" and "happen-after", and we say an evaluation |
See CWG2863. |
IIUC, CWG2863 seems not clear this example: std::atomic<std::shared_ptr<int>> ptr;
// thread 1:
std::shared_ptr<int> x(new int); //#0
new (x.get()) int{1}; //#1
ptr.store(x,std::memory_order_release); // #2
//thread 2:
auto p = ptr.load(std::memory_order_acquire); // #4
int I = *(p.get()); // #5 Assuming, in this case,
yes
no
yes, E happens-after the lifetime of O ends
E happens-after the storage which O occupied is reused, so it's false. Whether E happens before the storage which Does it mean, the pointer |
The intent is that we have a transparent-replacement case here; see discussion in the reflector thread starting at http://lists.isocpp.org/core/2024/04/15756.php |
How can I access this website? The website seems to need authorization |
Please contact your national standardization body and ask to participate in ISO/IEC JTC1 SC22 WG21. |
Another example is: #include <iostream>
int main(){
int* ptr = new int;
int v = *ptr; //#1
} The wording in P2434 says:
In this example, we don't know whether If we cannot prove an evaluation Similarly, CWG2863 has the same issue of whether E happens before the storage is released, so it is also unclear whether |
Such reading seemingly indicates that a leaked storage is effectively invalid at first, because the end of the duration of that storage doesn't exist and nothing can happen before such an end. But, IMO, we generally think the end to be in the infinite future or at the termination of the program, so everything happens before such an end. I'm not sure whether wording fix is necessary. |
Incidentally, Even if we say the evaluation that uses We may say
|
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[basic.life] p9 says:
This wording is changed to
Consider this example:
The new-expression at
#1
comprises reusing the storageptr
points to and creating an object at the storage, however, [basic.life] p9 requires that: before the storage which the object occupied is reused or releasedThis implies that the creating object at
#1
should happen before the storage is reused at#1
, however, it is underspecified whether the new-expression at#1
happens before itself. Strictly speaking, does the creating object in the expression happen before the storage reusing in the same expression?The text was updated successfully, but these errors were encountered: