You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove notion of "preferred" alignment AKA __alignof
In rust-lang#90877 (comment)
T-lang decided they did not wish to remove `intrinsics::pref_align_of`.
However, the intrinsic
1. is a nightly feature, so can be removed at compiler/libs discretion
2. requires considerable effort in the compiler to support
3. has been justified based on relevance to codegen, but it is only a
requirement for C++ (not C, not Rust) stack frame layout for AIX[^1],
in ways Rust would not interact with, even with increased C++ interop
4. the AIX XLC compiler's layout rules for C have unrelated concerns[^2]
5. otherwise it is used to pad static layout[^3], not correctness
6. these static align-up clauses can be replaced by other rules
7. there is only one clear benefactor we are aware of:
tools automating C -> Rust translation handling GNU extensions[^4].
8. because the GNU extension is a "false friend" of a standard C form,
`alignof` or `_Alignof`, the C code likely meant `mem::align_of`,
which makes the choice to support such a mapping very questionable
9. its presence makes it easy to do incorrect codegen with the compiler,
as Rust rules regarding alignment (e.g. size == align * N) do not hold
with preferred alignment, and this actually happened[^5]
Thus remove the intrinsic and supporting code, as a cost-benefit analysis
cannot possibly justify going to such lengths and risking correctness
just to help automated translation of an ill-considered GNU extension.
[^1]: cite AIX cookie layout
[^2]: cite AIX "power alignment" issues
[^3]: cite static alignment usages
[^4]: cite c2rust commit
[^5]: cite bjorn3's PR
0 commit comments