Boost logo

Boost :

Subject: Re: [boost] [align] Review - Impl Evaluation Part 1.
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2014-04-15 19:19:45

Glen Fernandes <glen.fernandes <at>> writes:

> On Sat, Apr 12, 2014 at 1:11 PM, Mostafa <mostafa_working_away <at>> wrote:
> > Unfortunately I don't understand what you're trying to say.
Additionally let
> > me rephrase my question, why is it that in the absence of a
> > platform-specific aligned_alloc the boost provided aligned_alloc
> > aligns on alignof(void *) if the user requested alignment value is less
> > alignof(void *)? (I understand this is still correct behaviour, just
> > since the boost provided aligned_alloc uses boost::align to align the
> > buffer and, per your previous response, "An alignment smaller than
> > alignof(void*) is still a valid fundamental alignment, so align()
should be
> > usable with such values.")
> Ah, I had misinterpreted your question. The reason why the
> Boost-provided aligned_alloc will ensure alignment is a minimum of
> alignof(void*), is because after calling align(), we want to access
> the sizeof(void*) bytes immediately preceding the aligned memory as a
> void*, so that address must be suitably aligned for void*.
> Instead of *(static_cast<void*>(p1) - 1) = p2; I could have used
> std::memcpy to copy p2 into that storage, and then it would not
> require that storage to be at-least alignof(void*) aligned.
Thanks for the explanation. Then I think the documentation
for aligned_alloc needs to be updated from:
  "... by an additional sizeof(void*) and alignment bytes."
  "... by an additional sizeof(void*) and max(alignment, sizeof(void *))
to take into account the silent alignment bumping that may occur in some

Boost list run by bdawes at, gregod at, cpdaniel at, john at