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
Because of the pass-by-value semantics ptr should get the copy of b and thus a different pointer should be returned from the function. (A pointer to the local value indeed, which is an issue on its own, but different then the one described here.)
Since ptr is actually getting the pointer to the original value and no copy is made writing to ptr_b overwrites b.
Notice that if we don't use _addr_of (or references one day) to the immutable parameters, the fact that the copy is not made is a valid optimization.
The text was updated successfully, but these errors were encountered:
ironcev
changed the title
Pass by-value semantics not preserved when using __addr_of
Pass-by-value semantics not preserved when using __addr_of
Nov 1, 2023
This fixes a bug in `local_copy_prop_prememcpy` which didn't
make an exception when a local gets passed its address into
another function, thus making it unsafe to optimize it.
Closes#5250
Related to #4600
This fixes a bug in `local_copy_prop_prememcpy` which didn't make an
exception when a local gets passed its address into another function,
thus making it unsafe to optimize it.
Closes#5250
Related to #4600
Consider the following test that is passing on
v0.46.0
and the Sway latest master branch:Because of the pass-by-value semantics
ptr
should get the copy ofb
and thus a different pointer should be returned from the function. (A pointer to the local value indeed, which is an issue on its own, but different then the one described here.)Since
ptr
is actually getting the pointer to the original value and no copy is made writing toptr_b
overwritesb
.Notice that if we don't use
_addr_of
(or references one day) to the immutable parameters, the fact that the copy is not made is a valid optimization.The text was updated successfully, but these errors were encountered: