Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rjmccall
Copy link
Collaborator

Addresses issue #119.

@rjmccall rjmccall changed the title Be more precies about array cookies Be more precise about array cookies Mar 16, 2021
abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
Copy link
Contributor

@zygoloid zygoloid left a 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.

abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
abi.html Show resolved Hide resolved
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.
@rjmccall
Copy link
Collaborator Author

rjmccall commented May 9, 2023

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 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.

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>
Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jensmaurer
Copy link

Is there any need to discuss this with WG21's CWG?

@rjmccall
Copy link
Collaborator Author

rjmccall commented May 9, 2023

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 delete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants