frankpfenning / C0

C0 Language
4 stars 0 forks source link

Wrappergen must check types #63

Closed robsimmons closed 9 years ago

robsimmons commented 9 years ago

makelibs/load_h0.c0 makes a scary undocumented assumption: that any named type is actually a pointer (and therefore can be cast directly to void*). The 441 library violates this assumption, which may break other invariants and lead to bugs in VM implementations (VM implementations shouldn't be using the 441 library, but they nevertheless can).

gcc -g -fPIC -I../../include  -c 15411_c0ffi.c -o 15411_c0ffi.o
15411_c0ffi.c: In function ‘__c0ffi_fadd’:
15411_c0ffi.c:29: warning: cast from pointer to integer of different size
15411_c0ffi.c:29: warning: cast from pointer to integer of different size
15411_c0ffi.c:29: warning: cast to pointer from integer of different size
15411_c0ffi.c: In function ‘__c0ffi_fsub’:
15411_c0ffi.c:33: warning: cast from pointer to integer of different size
15411_c0ffi.c:33: warning: cast from pointer to integer of different size
15411_c0ffi.c:33: warning: cast to pointer from integer of different size
15411_c0ffi.c: In function ‘__c0ffi_fmul’:
15411_c0ffi.c:37: warning: cast from pointer to integer of different size
15411_c0ffi.c:37: warning: cast from pointer to integer of different size
15411_c0ffi.c:37: warning: cast to pointer from integer of different size
15411_c0ffi.c: In function ‘__c0ffi_fdiv’:
15411_c0ffi.c:41: warning: cast from pointer to integer of different size
15411_c0ffi.c:41: warning: cast from pointer to integer of different size
15411_c0ffi.c:41: warning: cast to pointer from integer of different size
15411_c0ffi.c: In function ‘__c0ffi_fless’:
15411_c0ffi.c:45: warning: cast from pointer to integer of different size
15411_c0ffi.c:45: warning: cast from pointer to integer of different size
15411_c0ffi.c: In function ‘__c0ffi_itof’:
15411_c0ffi.c:49: warning: cast to pointer from integer of different size
15411_c0ffi.c: In function ‘__c0ffi_ftoi’:
15411_c0ffi.c:53: warning: cast from pointer to integer of different size
15411_c0ffi.c: In function ‘__c0ffi_print_fpt’:
15411_c0ffi.c:57: warning: cast from pointer to integer of different size

Wrappergen will need to actually read in typedefs and expand types to deal with this correctly: a significant but necessary complication.

robsimmons commented 9 years ago

This has been resolved alongside the changes to the FFI to support runtime checking of integer/pointer values.