You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the function is not designed to work with non-standard int sizes, a compiler check could be added to detect improper usage ( e.g. by checking if the packed size is same as size with padding).
Additionally, documentation could be improved to clearly state this (currently, the docs for the function state the following:)
/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type
/// backed by those bytes, preserving pointer attributes.
The text was updated successfully, but these errors were encountered:
zxubian
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Sep 24, 2022
Zig Version
0.9.1 (windows, chocolatey)
Steps to Reproduce
Compile and run the following code:
Expected Behavior
Code compiles and runs.
Log output should print out "0".
Actual Behavior
The following error is printed out:
This is because BytesAsValueReturnType in std.mem uses
@sizeOf
to obtain the size of the type. However, this will include the size of the padding, causing a size mismatch.If the function is not designed to work with non-standard int sizes, a compiler check could be added to detect improper usage ( e.g. by checking if the packed size is same as size with padding).
Additionally, documentation could be improved to clearly state this (currently, the docs for the function state the following:)
The text was updated successfully, but these errors were encountered: