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
The result of wrap is a dangling pointer to arr. That is to say, after the function returns, arr is popped off the stack, and gets overwritten by other memory e.g. variables declared in later functions using the same stack. This is undefined behavior, not a bug.
There is ongoing discussion about that. There was a pull request adding such a compile error, but it wasn't merged as it is unclear how to write it into the spec for now.
Related: #5725, #11153
Zig Version
0.11.0-dev.251+7c527c6df
Steps to Reproduce and Observed Behavior
Expected Behavior
A compiler error to prevent dangling pointer
The text was updated successfully, but these errors were encountered: