pervognsen / bitwise

Bitwise is an educational project where we create the software/hardware stack for a computer from scratch.
Other
5.13k stars 213 forks source link

Incorrect type info for void const * type #33

Closed mcavanagh closed 6 years ago

mcavanagh commented 6 years ago
@foreign
func memcpy(dst: void*, src: void const *, size: usize): void*;

compiles ok, but outputs

[1] = &(TypeInfo){TYPE_VOID, .name = "void"},
  ...
[35] = &(TypeInfo){TYPE_CONST, .size = sizeof(void const ), .align = alignof(void const ), .base = 1},

(note the missing *), leading to the C compiler to report:

main.ion(292): warning C4034: sizeof returns 0
main.ion(292): error C2714: alignof(void) is not allowed

The line number is also off (past the end of the ion file), but this might be a knock-on effect.

pervognsen commented 6 years ago

Thanks, this will be fixed. Note that the generated type info is actually "correct", there's no missing asterisk. What you're seeing is the (const void) part of (ptr (const void)). It's just that I have to be more careful about generating sizeof/alignof something with size 0.

pervognsen commented 6 years ago

Fixed.