MCP: repr(align(ptr)) #35
Labels
charter-needed
A project proposal that has been approved as a new project group, but no charter has been written.
major-change
Major change proposal
T-lang
The
AtomicPtr
type needs three lines of cfg_attr just to try and say what it really wants to say, "I am aligned to the size of a pointer". This is slightly silly, and what's worse it's actually a little error prone because if the pointer width were ever smaller (unlikely) or larger (not impossible) then suddenly none of the cfg_attr would apply and not only would it not have the right alignment it wouldn't even have repr(C), which could make other code that assumesAtomicPtr
has repr(C) also suddenly be UB.Conclusion the
align()
attribute should allow a value ofptr
to request pointer alignment for your type in a "blessed" portable way.The text was updated successfully, but these errors were encountered: