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.

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

Reply via email to