Init new repository
This commit is contained in:
21
tests/field_pointer_offset.txt
Normal file
21
tests/field_pointer_offset.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
import "libc";
|
||||
Some_Struct :: struct {
|
||||
i: *int;
|
||||
}
|
||||
|
||||
main :: proc(): int {
|
||||
i: [4]int = {1, 2, 3, 4};
|
||||
s: Some_Struct = {i = addptr(i, 1)};
|
||||
|
||||
assert(s.i[0] == 2);
|
||||
assert(s.i[-1] == 1);
|
||||
assert(s.i[1] == 3);
|
||||
|
||||
assert(addptr(s.i, 1)[0] == 3);
|
||||
assert(*addptr(s.i, -1) == 1);
|
||||
assert(addptr(s.i, -1)[0] == 1);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user