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
I suspect that this is because the self parameter is passed by copy and the copy happens before the arguments are evaluated. Since there is no control over the fact that the struct is passed by copy or by reference, the behavior isn't consistent based on the size of the struct.
A workaround today is to always pass the self argument as a pointer or const pointer.
Working as intended; evaluation is always left-to-right. The inconsistency based on struct size is going to be fixed by the elimination of PRO's semantic implications (#5973).
Zig Version
0.13.0 but also trunk on godbolt
Steps to Reproduce and Observed Behavior
Hello,
The following code will return
done 0
whereas I would have expecteddone 1
:I suspect that this is because the self parameter is passed by copy and the copy happens before the arguments are evaluated. Since there is no control over the fact that the struct is passed by copy or by reference, the behavior isn't consistent based on the size of the struct.
A workaround today is to always pass the self argument as a pointer or const pointer.
Godbolt link: https://godbolt.org/z/dTEaPe3d3
Expected Behavior
The struct copy should be done after the arguments are evaluated so the result is
done 1
in the example provided.The text was updated successfully, but these errors were encountered: