diff options
author | Araq <rumpf_a@web.de> | 2015-08-04 17:31:00 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-08-04 17:31:18 +0200 |
commit | ab26298a035ed794fc73724a6ae06eefd6c764d3 (patch) | |
tree | 92eabb800ac80655ec3036633f8bbe519fe94060 /tests/ccgbugs/tunsafeaddr.nim | |
parent | f8f967720598ad75ec0e0db68a983cbcdd39145d (diff) | |
download | Nim-ab26298a035ed794fc73724a6ae06eefd6c764d3.tar.gz |
added system.unsafeAddr
Diffstat (limited to 'tests/ccgbugs/tunsafeaddr.nim')
-rw-r--r-- | tests/ccgbugs/tunsafeaddr.nim | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ccgbugs/tunsafeaddr.nim b/tests/ccgbugs/tunsafeaddr.nim new file mode 100644 index 000000000..4f05c7c21 --- /dev/null +++ b/tests/ccgbugs/tunsafeaddr.nim @@ -0,0 +1,19 @@ +discard """ + output: '''12''' +""" + +{.emit: """ +long sum(long* a, long len) { + long i, result = 0; + for (i = 0; i < len; ++i) result += a[i]; + return result; +} +""".} + +proc sum(a: ptr int; len: int): int {.importc, nodecl.} + +proc main = + let foo = [8, 3, 1] + echo sum(unsafeAddr foo[0], foo.len) + +main() |