Open spytheman opened 2 hours ago
Note: a very similar program, compiles and runs:
union Convertor {
su8_array_p [20]u8
sint_array_p [5]int
}
a := [1,2,3,4,5]!
p := voidptr( unsafe { &Convertor( &a[0] ) } )
c := unsafe { &Convertor( p ) }
dump(a)
dump(p)
dump(c)
dump(unsafe { c.su8_array_p } )
producing:
[a.v:9] a: [1, 2, 3, 4, 5]
[a.v:10] p: 0x7fffffffd74c
[a.v:11] c: &Convertor{
su8_array_p: [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]
sint_array_p: [1, 2, 3, 4, 5]
}
[a.v:12] unsafe { c.su8_array_p }: [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]
union Convertor {
su8_array_p [20]u8
sint_array_p [5]int
}
a := [1,2,3,4,5]!
p := voidptr( unsafe { &Convertor( &a[0] ) } )
dump(a)
dump(p)
dump(unsafe { &Convertor( p ).su8_array_p } )
this also compiles and runs fine.
V doctor:
What did you do?
./v -g -o vdbg cmd/v && ./vdbg a.v
What did you expect to see?
a compiled program
What did you see instead?