-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Example
proc mutate(x:var float) = x = 3.9 proc a(degree:int) = echo "a: ",degree var x = create(UncheckedArray[float],degree) #second call returns the same pointer, #var x = cast[ptr UncheckedArray[float]](alloc0(sizeof(float)*degree)) #works echo x.repr doAssert(x[0]==0.0) mutate(x[0]) x.dealloc() proc main() = a(3) a(7) a(3) main()Current Output
a: 3 ptr 0x7fe7c52e5048 --> [...] a: 7 ptr 0x7fe7c52e5048 --> [...] /usercode/in.nim(21) in /usercode/in.nim(18) main /usercode/in.nim(12) a /playground/nim/lib/system/assertions.nim(29) failedAssertImpl /playground/nim/lib/system/assertions.nim(22) raiseAssert /playground/nim/lib/system/fatal.nim(49) sysFatal Error: unhandled exception: /usercode/in.nim(12, 11) `x[0] == 0.0` 3.9 [AssertionError] Expected Output
a: 3 ptr 0x7fad8198f070 --> [...] a: 7 ptr 0x7fad81990120 --> [...] a: 3 ptr 0x7fad8198f160 --> [...] with --gc:arc the above work
Nim Compiler Version 1.5.1 [Linux: amd64] Compiled at 2021-06-20 Copyright (c) 2006-2021 by Andreas Rumpf git hash: ad5063aed101f0102fb867f0b4e518ede7fa188b active boot switches: -d:release Metadata
Metadata
Assignees
Labels
No labels