rui314 / 8cc

A Small C Compiler
MIT License
6.13k stars 740 forks source link

failed assertion. #23

Closed andrewchambers closed 9 years ago

andrewchambers commented 9 years ago

Using creduce to find bugs in 8cc. First one.

short a;
void fn1() { -a; }

-> 8cc: parse.c:525: usual_arith_conv: Assertion `is_inttype(t) && t->size >= type_int->size' failed.

andrewchambers commented 9 years ago

I think it is unary - not promoting its value with conv, unary minus is done as a binop('-',0,x); where the 0 is the same type as x. This means it attempts to promote x to type short, which fails the assertion above.

andrewchambers commented 9 years ago

addressed in #30. handle it there.