zsaleeba / picoc

A very small C interpreter
1.45k stars 183 forks source link

Character constants are incorrectly typed #23

Open joesavage opened 8 years ago

joesavage commented 8 years ago

Character constants in C should be of the int type (see C99 §6.4.4.4 paragraph 10), yet using picoc the following snippet produces '1' in cases where it should produce '0' (e.g. when sizeof(int) == 4 and sizeof(char) == 1):

#include <stdio.h>

int main(void) {
    char input = 'A';
    printf("%d\n", sizeof(input) == sizeof('A'));
    return 0;
}