-
Notifications
You must be signed in to change notification settings - Fork 94
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
Be more precise about array cookies #123
base: main
Are you sure you want to change the base?
Conversation
5eb76bb
to
097f1f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we need to handle the awkward situation of the cookie requiring more alignment than new guarantees to provide, somehow.
Per discussion with @zygoloid, the standard does not permit cookie alignment to be factored into allocations, either by changing the resolution of operator new[] or changing the `std::align_val_t` argument. We could ask for this to be changed, but it's not clear that there's any reasonable solution for class-specific allocators that don't take an explicit alignment, which it seems reasonable to say should be allowed to return something based on the alignment of the class. Given that, the only reasonable decision is to not always align the cookie. We should still be able to assume it's aligned in common cases.
I've updated the PR per an offline conversation with @zygoloid. The standard does not appear to permit cookie alignment to be factored into allocations, either by changing the resolution of operator new[] or changing the Implementations should still be able to assume the cookie is aligned in common cases. I will leave this open for this rest of this week for review. |
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Is there any need to discuss this with WG21's CWG? |
My understanding is that Richard asked the reflector about it a few years ago and didn't get any response. If the committee decides in the future that implementations can/should upgrade the alignment of array allocations, it's mostly non-ABI-breaking for us to start doing that. The only concern would be what alignment we can assume in |
Addresses issue #119.