[PATCH] D118804: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 8 04:27:50 PST 2022


aaron.ballman added a comment.

In D118804#3303004 <https://reviews.llvm.org/D118804#3303004>, @jyknight wrote:

> In D118804#3302675 <https://reviews.llvm.org/D118804#3302675>, @rsmith wrote:
>
>> I support this revert.
>
> Having received enough support, I'll go ahead and commit, and then propose backport to llvm 14 branch.
>
> But --
>
>> - `malloc` always returns storage whose alignment is at least the largest fundamental alignment.
>
> As has been discussed previously in this review thread, that's not true -- and the in-practice-falseness of this statement was the trigger for reverting the change.
>
> Not only is it not true in practice, it was clarified for C2x such that it's definitely not true per standard, either (while, before, it was unclear and could've been read either way). The current wording in C2x is: "The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object with a fundamental alignment requirement and size less than or equal to the size requested.", see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2293.htm

As the community's WG14 representative, I can confirm this information. We discussed N2293 in Pittsburgh in 2018 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2375.pdf) and the proposal had unanimous consent from the committee. WG14 is still establishing their new DR process, so the committee had no way to flag this as a defect report that applies retroactively to prior standards, but given the purpose of the paper was to clarify the intent, I think it is reasonable for us to treat it as a defect in all C versions if we wish to do so, not just C2x.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118804/new/

https://reviews.llvm.org/D118804



More information about the cfe-commits mailing list