-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
The upcoming behavior of reinterpret
for isbits types is dubious and not explicitly documented
#52135
Comments
|
Correction on 3 - I see that ReinterpretArray's version would be hard to make consistent, as it stacks padding in-place. Both concepts IMO make sense for their own types. But perhaps in 2.0 they should be separated, and for now the documentation could be clarified on the differences. |
vtjnash
pushed a commit
that referenced
this issue
Feb 13, 2024
As suggested in #52135, I've added some to the `reinterpret` docs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The upcoming behavior of
reinterpret
for "plain data" types, introduced in #47116, is to reinterpret only the non-padding bytes of an isbits value. This generalizes the functionality compared to the latest release, v1.9, wherereintepreting
non-primitive isbits types was not allowed. Personally I'd like for this to get reverted, so I'm listing some issues with it, but at the very least consider this as a doc issue.Why expand the
reinterpret
API, which is already unsafe and IMO ugly (e.g., the reinterpret-for-isbits and reinterpret-for-arrays could really have been two different functions)?The behavior depends on the host endianness, and encourages user code whose correctness depends on the host-endianness. While little-endian is currently completely dominant, this expansion of the
reinterpret
API seems like an unecessary and subtle footgun for the Julia ecosystem, as it becomes a trap when some big-endian architecture becomes relevant again. Encouraging host-endianness-dependent behavior is especially weird given the "correctness bugs" scrutiny that Julia is subject to.The padding-handling for isbits-
reinterpret
types is inconsistent with the array-reinterpret
behavior. So, this works for a tuple, but fails for an array of such tuples:reinterpret
with essentials.jlreinterpret
#50367 then removed that doc string.The text was updated successfully, but these errors were encountered: