fuhsnn / slimcc

C11 compiler with GNU / C23 extensions for x86-64 Linux, able to build Python and PostgreSQL
MIT License
24 stars 3 forks source link

Conditional operator inconsistent type with operand swapped #41

Closed fuhsnn closed 9 months ago

fuhsnn commented 9 months ago
#include <stdio.h>
void main(int argc, char **argv) {
  void *p = 0;
  printf("%d\n", _Generic(argc ? p : "a", void*:1, char*:2 )); // expect 1, got 1
  printf("%d\n", _Generic(argc ? "a" : p, void*:1, char*:2 )); // expect 1, got 2

  printf("%d\n", sizeof(argc ? "a" : 0)); // expect 8, got 8
  printf("%d\n", sizeof(argc ? 0 : "a")); // expect 8, got 4
}