-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
This code shows different results when compiled with ARC or refc. Found in one of the tests in https://github.com/fox0430/moe
Example
# from sequtils
proc insert(dest: var seq[char], src: openArray[char], pos = 0) =
var j = len(dest) - 1
var i = len(dest) + len(src) - 1
dest.setLen(i + 1)
while j >= pos:
when defined(gcDestructors):
dest[i] = move(dest[j])
else:
dest[i].shallowCopy(dest[j])
dec(i)
dec(j)
inc(j)
for item in src:
dest[j] = item
inc(j)
var newLine = @['a']
let indent = newSeq[char]()
echo "new line before - ", newline
newline.insert(indent, 0)
echo "new line after - ", newlineCurrent Output
With ARC:
new line before - @['a']
new line after - @['\x00']
refc:
new line before - @['a']
new line after - @['a']
Expected Output
Not sure which one of these is correct.
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-07-15
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: e057b1d8395f4d639e195bc8f6a7e6922c149201
active boot switches: -d:release -d:danger
Metadata
Metadata
Assignees
Labels
No labels