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
this PR nim-lang#15466 enabled one to write let a = someConst.unsafeAddr; however this feature is buggy
Example 1
unsafeAddr doesn't work with most types
whentrue:
templatefn(a) =const b = a
let c = b.unsafeAddr
type A =object
a0: inttype B =ref A
fn [1,2]
fn@[1,2]
fnA(a0:1)
# these don't work: Error: expression has no address# fn "ab"# fn (1, 2)# fn 1# fn B(a0:1) # this one would work with const ref PR https://github.com/nim-lang/Nim/pull/15528
note that these would work with let c = b instead of let c = b.unsafeAddr
Example 2
whentrue:
const a = [1,2]
procfn=let a1 = a.unsafeAddr
a1[][0] =7echo a1[]
echo a
static: fn()
fn()
this PR nim-lang#15466 enabled one to write
let a = someConst.unsafeAddr
; however this feature is buggyExample 1
unsafeAddr doesn't work with most types
note that these would work with
let c = b
instead oflet c = b.unsafeAddr
Example 2
vm:
[7, 2]
[1, 2] # inconsistent
rt:
SIGBUS
Example 3
prints:
4416151424
4416151424
4416151440 # address of a returned is different depending on which module it was called from
4416151440
and this is generated in each module:
unlike what was required in nim-lang/RFCs#257
Example 4
unsafeAddr
still doesn't help with types that (transitively) contain ref/ptr; it still needs nim-lang#15528Example 5
vm:
4378615304
4378615368 # different from previous line (inconsistent)
rt:
4382200032
4382200032 # same from previous line
Example 6
Example 7
nim r main: SIGBUS
nim r -b:cpp main: prints @[7, 2]
Example 8
nim r main: prints [1, 2] with -d:danger, or SIGBUG without
nim r -b:cpp main: prints [7, 2] with or without -d:danger
Additional Information
1.5.1 2b5841c
links
for ai in a
has quadratic complexity in VM whena
is const nim-lang/Nim#16790EDIT => nim-lang#16794
The text was updated successfully, but these errors were encountered: