-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[ARC] compile-time move()
on a sink-annotated argument empties the original value even when it's unsafe
#17199
Labels
Comments
ghost
added
the
ARC/ORC Memory Management
label
Feb 28, 2021
ghost
changed the title
[ARC] Sequence becomes empty after using system.
[ARC] move on a sink-annotated argument empties the original value even when it's unsafe
Feb 28, 2021
&
in compile-time context
I'm not sure if this can actually be considered an ARC bug since it can happen with both arc and refc - so maybe we should either make the |
ghost
changed the title
[ARC] move on a sink-annotated argument empties the original value even when it's unsafe
[ARC] compile-time Feb 28, 2021
move()
on a sink-annotated argument empties the original value even when it's unsafe
Example from #16847 : macro Bug() =
let a = @[123]
discard @[456] & a
let c = @[789] & a
assert c[1] == 123
Bug() |
ghost
mentioned this issue
Mar 8, 2021
Example from #17294: proc recurse(strings:seq[string],recursionsLeft:int) =
if recursionsLeft != 0:
echo "Before call: " & $strings
recurse(strings & @["another string"],recursionsLeft-1)
echo "After call: " & $strings
else:
discard
static:
recurse(@["string"],1) |
Sink parameters are currently under the ARC/ORC umbrella. |
ghost
mentioned this issue
Mar 10, 2021
Clyybber
added a commit
to Clyybber/Nim
that referenced
this issue
Mar 12, 2021
Merged
Clyybber
added a commit
to Clyybber/Nim
that referenced
this issue
Mar 25, 2021
Clyybber
added a commit
that referenced
this issue
Mar 26, 2021
* don't zero out in a move in the VM * Add testcases for #17199 * Update tests/arc/tarcmisc.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> * Update tests/vm/tissues.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> * Fix test failures * Fix test * Fix tests Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code works fine with refc but fails with arc because system has a different implementation for https://nim-lang.org/docs/system.html#%26%2Cseq%5BT%5D%2CT and with ARC the compiler seems to always pass a variable to a
sink
-annotated argument even when it's unsafe. Found in https://github.com/PMunch/protobuf-nimExample
Original example
Example with & taken out of system (fails with both refc/arc):
Current Output
Expected Output
Successful compilation
The text was updated successfully, but these errors were encountered: