On Wed, Dec 17, 2025 at 3:42 PM Eugene Syromyatnikov <[email protected]> wrote:
>
> On Wed, Dec 17, 2025 at 2:51 PM Alejandro Colomar <[email protected]> wrote:
>
>
> > +Otherwise,
> > +the behavior was undefined.
>
> I think this statement is incorrect, or at least misleading, because
> the current reading (that includes DR460) of ISO 9899:2011 explicitly
> states that the function must fail when the condition is not satisfied
> (and that is what OpenBSD has implemented), and that also makes any
> permissive specification non-conforming wrt C11 as it is now. But that
> is also true that C11 _used to_ specify a failure to conform to this
> onerous restriction as UB, which rendered the programs malformed, but,
> on the other hand, kept libcs that implemented it permissively
> standard-conformant.
>
> I understand that I am unnecessarily conscientious here, but I think
> it is important to articulate what the standard both says and used to
> say, as it is the reference point for the language implementations,
> the totality of which an application developer can neither observe nor
> inspect, and relying on a couple of anecdotes in terms of
> implementations may lead to issues down the road. I guess the outcome
> of my rants is "don't use aligned_alloc and C11 together", or
> something along those lines.

Correction: I was thinking that there was a published TR similar to
C++, but apparently there wasn't, so the UB-including wording has
never updated in publicly-available iterations of C11, the next
published version, that is C17, has removed the requirement
altogether, and the version with the
failing-on-size-non-multiple-of-alignment requirement was never
publicly available similar to the ways standard drafts are, while
technically the wording existed for two years before the adoption of
N2072, hence my blabber about the "final version of C11" is
nonsensical;  however, the point about the standard requiring three
different things still stands. My apologies for the excessive noise.


> > +.IP \[bu]
> > +If
> > +.I alignment
> > +was not a power of two,
> > +the behavior was undefined.
>
> I can't find a version of the standard that mentions the power-of-two
> restriction, it pertains only posix_memalign.
>
> --
> Eugene Syromyatnikov
> mailto:[email protected]
> xmpp:esyr@jabber.{ru|org}



--
Eugene Syromyatnikov
mailto:[email protected]
xmpp:esyr@jabber.{ru|org}

Reply via email to