-
-
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
Round-trip reintrepretation of all bits types #47116
Conversation
As mentioned in the original PR, this at least needs docs to warn about the possibility of creating potentially illegal instances this way. I don't think this has been addressed in general yet, has it? Since the behavior of "ignore padding and just fill "valid" bits" behavior is kind of unusual, that should probably be documented as well. |
This comment was marked as outdated.
This comment was marked as outdated.
If people feel it's necessary to narrow what conversions are allowed though, that's valid. I approached this from a "well, why not allow this?" perspective. But like, if we wanted to require same-size-primitives or same-type-primitives, and then special case UInts as universally convertible, I could see that allowing most reinterpretations that could be desired normally. |
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Also, the doc change mentioned above also isn't in the PR yet, as far as I can tell - important not to forget, I think :) |
Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com>
Just added docstring and I think the test suite passed (yes - only failures are general CI issues). Two items to consider:
|
Those items to consider can be done as followup after merging this |
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
When building julia, there is now the following:
See for instance https://buildkite.com/julialang/julia-master/builds/25396#01890455-aaaf-4e11-a538-619a97d6db6c/1343-2975 in CI. |
Hmm... So the bitcast of primitive types needs to be available via Lines 545 to 560 in e4600c5
Maybe it could be replaced with:
And the |
would be better. |
Successor to #32660 and rebasing of #45723 onto master.
This PR allows any bits type to be safely reinterpreted as any other bits type containing the same number of valid bytes, regardless of how either type is padded.
Example: