-
-
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
const cstring incorrectly cgen'd (pointer is copied, pointing to garbage) #12334
Comments
reduced: when true: # D20201024T083352
const a = "foo"
const b: cstring = a
# const b: cstring = "foo" # would work
var c = b
echo (a.repr, b.repr, c.repr, a, b, $b, c, c.len, cast[int](c), cast[int](b)) prints: so the title is wrong, the cstring is not empty, it's just that the cstring is being copied incorrectly (the pointer is copied directly instead of copying the content it points to) when crossing the VM => RT boundary noteanother unrelated issue I found is: when true: # D20201024T085220:here
const a = "foo"
var b: cstring = a
echo (a.repr, b.repr) ("0x10d7dff98"foo"", "0x10d7df518"foo"\n") |
fixes #12334 `nkHiddenStdConv` shouldn't be removed if the sources aren't literals, viz. constant symbols.
Actual output: empty
Expected output:
Offending commit: 85db42a
The issue can be worked around with the following pattern:
o.a = static(cstring(foo))
The text was updated successfully, but these errors were encountered: