-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
codegen incorrect for some kinds of aliasing #103
Comments
We can perhaps salvage the ability to make functions accept byvalue structs by implicitly adding noalias to byval parameters if the function body does not modify memory outside the stack. This is a little cumbersome to constantly reason about though, so perhaps it may be common practice to accept |
Another option: make byval parameters illegal, if the handle of the type is a pointer. In other words, any type which isn't a simple scalar would be an illegal argument type. For extern/export functions which interact with C ABI, we can allow byval parameters, and keep the C byval semantics. |
See also #83 |
If we follow this idea of making byval parameters illegal when the handle of the type is a pointer, this would make it illegal to pass type |
what's the plan for allowing user types to be passable byval? #83 mentions a copyable attribute. wouldn't that obviate this entire issue? running with the copyable concept, we should probably make |
In Zig, parameters are supposed to be immutable. But when
dont_modify_param
setsglobal_array[0] = 0
, it succeeds in modifying the bytes ofparam
.To fix this, zig must copy bytes before sending a byvalue parameter under the following condition:
The text was updated successfully, but these errors were encountered: