Open rjmccall opened 3 years ago
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.
Is there any need to discuss this with WG21's CWG?
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
.
Addresses issue #119.