-
Notifications
You must be signed in to change notification settings - Fork 60
Layout of multi-dimensional arrays #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Multi-dimensional arrays are not a primitive concept -- in |
Currently, this actually does not seem to be guaranteed, due to this sentence: "The alignment of array types is greater or equal to the alignment of its element type." Notice the 'greater or equal'. If I'm not an expert on data type layout, so I don't know why it says 'greater or equal'. |
possibly to leave room for automatic simd conversion. |
I would assume that (for a It does say, for From the wording in the reference, it sounds like, either it depends whether
It's ambiguous, in my opinion. It should also be added that in any case, C does not allow this kind of type-reinterpretation, it's UB but by the language's own rules does work. |
This is regardless of |
We could key off of Since we have |
I noticed the Layout of Rust array types and slices chapter from the Unsafe Code Guidelines doesn't mention anything about the layout of multi-dimensional arrays.
Can it be assumed that a
[[T; N]; M]
will have the same layout as a[T; N*M]
?I believe you can infer it to be true based on the first three paragraphs, but I thought I'd double-check because it doesn't explicitly mention anything about multi-dimensional arrays.
The text was updated successfully, but these errors were encountered: