File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ pub fn (mut p Pool) type_struct_info(typ ast.Type) ?StructInfo {
5858}
5959
6060pub fn (mut p Pool) type_size (typ ast.Type) (int , int ) {
61+ if typ.nr_muls () > 0 {
62+ return p.table.pointer_size, p.table.pointer_size
63+ }
64+
6165 ts := p.table.sym (typ)
6266 if ts.size != - 1 && typ.idx () in p.structs {
6367 return ts.size, ts.align
Original file line number Diff line number Diff line change @@ -82,7 +82,24 @@ fn run_defer() {
8282 defer_if(false)
8383}
8484
85+ struct HasPointers {
86+ a int
87+ msg &string
88+ pub mut:
89+ same &HasPointers
90+ }
91+
92+ fn ptr_in_struct() {
93+ msg := 'pointer in struct'
94+ mut s := HasPointers{1234, &msg, unsafe { nil }}
95+ println(*s.msg)
96+ s.same = &s
97+ println(*&int(voidptr(s.same.a))) // FIXME: wont work without casts
98+ }
99+
85100fn main() {
101+ println('ptr_in_struct')
102+ ptr_in_struct()
86103 println('ptr_arith')
87104 ptr_arith()
88105 run_defer()
Original file line number Diff line number Diff line change 1+ ptr_in_struct
2+ pointer in struct
3+ 1234
14ptr_arith
2512
3614
You can’t perform that action at this time.
0 commit comments