-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
a = f(a, b);
return value sometimes interfering with argument?
#3696
Comments
I believe (pretty sure) this is the same phenomenon as #3234: Zig currently doesn't introduce a temporary for reassignment of a union, struct, or array, test "array reassignment"{
var a = [_]i32{1, -1};
a = .{a[0] + a[1], //written first: a[0] is now 0
a[0] + a[1]}; //read afterwards, resulting in 0 + (-1)
if(a[0] != 0 or a[1] != -1) unreachable;
} The same thing happens in the second (I believe the first |
Another bug caused by this: #8330 |
Not really, this issue is about the return value's result location pointer aliasing with the argument's hidden pointer, in #8330 the issue is caused by an optimization not honoring promises about aliasing. |
You're right, it's a better fit for #5973 instead. Parameter passing in 8330 is not an optimization, these are the current language semantics. |
This code is giving different results based on implementation of
concatAll
. The implementations look equivalent.I have a feeling this has something to do with result locations. Is this how things are supposed to be?
Note: The matrix code here is not important - you can just run the different implementations and see that they output different results. Also, this is probably not the most efficient way to design a matrix library, but it's convenient (when it works).
The text was updated successfully, but these errors were encountered: