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
It is expected that &v == &v is true. Taking address of a variable should have no side effects.
The text was updated successfully, but these errors were encountered:
slonik-az
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Dec 4, 2023
slonik-az
changed the title
Parameter Reference Optimization (PRO) seems to violate basic address logic
Parameter Reference Optimization (PRO) violates basic address logic
Dec 4, 2023
slonik-az
changed the title
Parameter Reference Optimization (PRO) violates basic address logic
(&v != &v) for function parameters passed by value
Dec 4, 2023
One possible solution would be to follow Carbon language approach and ban taking address of the function parameter altogether (make it compile error). The rational for this drastic act being that compiler is free to put a parameter into a register, in which case no address is available anyway. If for some reason one needs the address of the object passed into the function one can change the function's signature and explicitly pass it by (const) pointer.
andrewrk
removed
the
bug
Observed behavior contradicts documented or intended behavior
label
Jan 9, 2024
Zig Version
0.12.0-dev.1606+569182dbb
Steps to Reproduce and Observed Behavior
Related to #16343. A new stack variable is created each time the address of the function parameter is taken resulting in
&v == &v
beingfalse
.Here is the repro
Expected Behavior
It is expected that
&v == &v
istrue
. Taking address of a variable should have no side effects.The text was updated successfully, but these errors were encountered: