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

`_Generic` selection error for pointers to qualified types #70

Closed fuhsnn closed 4 months ago

fuhsnn commented 4 months ago

Ignoring CV qualifiers may lead to miscompilation when _Generic is involved.

#include <stdio.h>
void fn1(const int*p){ printf("fn1\n"); }
void fn2(int *p){ printf("fn2\n"); }
int main(void) {
    const int p;
    _Generic(&p, const int*:fn1, int*:fn2)(&p); // expected fn1, got fn2
}
fuhsnn commented 4 months ago

Solved with 829a8ec