diff options
author | Araq <rumpf_a@web.de> | 2019-05-05 16:08:16 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-05-05 16:08:16 +0200 |
commit | 0ecaaa85e9395dc7ae947d6466698cef66f48f5c (patch) | |
tree | b4121b6d9e82bac94c38362ad3d0ce07eba1a1ce /tests/ccgbugs | |
parent | e42c304e4ae623ea8dea9594b531f119bb4142e9 (diff) | |
download | Nim-0ecaaa85e9395dc7ae947d6466698cef66f48f5c.tar.gz |
fixes #9403
Diffstat (limited to 'tests/ccgbugs')
-rw-r--r-- | tests/ccgbugs/tunsafeaddr.nim | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/ccgbugs/tunsafeaddr.nim b/tests/ccgbugs/tunsafeaddr.nim index 8d0a9d8cb..f868739de 100644 --- a/tests/ccgbugs/tunsafeaddr.nim +++ b/tests/ccgbugs/tunsafeaddr.nim @@ -1,5 +1,6 @@ discard """ - output: '''12''' + output: '''12 +4''' """ {.emit: """ @@ -26,3 +27,21 @@ p(@[1]) q(@[1]) main() + +# bug #9403 + +type + MyObj = ref object + len: int + val: UncheckedArray[uint64] + +proc spot(x: MyObj): int64 = + result = cast[UncheckedArray[int64]](x.val)[0] + +proc newMyObj(len: int): MyObj = + unsafeNew(result, sizeof(result[]) + len * sizeof(uint64)) + result.len = len + result.val[0] = 4u64 + result.val[1] = 8u64 + +echo spot(newMyObj(2)) |