Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
spec: ambiguity in definition of alignment #12947
The spec (September 24, 2015) says:
While intuitive, this definition doesn't address structs with blank fields (because there's no valid x.f expression to access those fields) or zero-element arrays (because x is an illegal expression, as 0 is a constant that's out of the array's bounds).
It seems like these can be addressed by changing the wording to something like:
(The original definition repeats the "but at least 1" wording each time, but that seems redundant since nothing else indicates that rule 1 is mutually exclusive with rules 2 and 3.)
@mdempsky Some of the wording here is historic - it's not clear that a field x.f is a "variable" hence some of the repetition. Furthermore, while I like your general rephrasing, it's less precise: unsafe.Alignof doesn't work on types, only expressions (including constants):
Should be clarified but is not urgent.
@griesemer Understood that
Hence why it seems reasonable to me to word alignment guarantees in terms of types too.