[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Patch: Treat func pointers with different return types as
From: |
Arthur Williams |
Subject: |
[Tinycc-devel] Patch: Treat func pointers with different return types as not compatible |
Date: |
Sun, 22 Nov 2020 14:58:42 -0800 |
I noticed a problem with tcc and _Generic that caused function pointers with different return types to be treated as compatible which would prevent the following code from compiling with the error "error: type match twice".
I'm aware that the person who originally added _Generic support was aware of this short coming and didn't fix it because that caused memmove and other internal functions from compiling. I updated the return types/declarations of such functions so that all current tests pass.
Minimal code snippet that didn't compile with tcc and will now compile:
#include <stdio.h>
#define G(P) _Generic(P, void(*)(int a):3, int(*)():0, void(*)(void):1, int :2)
void bar(void) {}
int foo() {return 0;}
int foo2(int a) {return 0;}
void foo3(int a) {}
int main() {
printf("%d\n", G(1));
printf("%d\n", G(bar));
printf("%d\n", G(foo));
printf("%d\n", G(foo2));
printf("%d\n", G(foo3));
}
- [Tinycc-devel] Patch: Treat func pointers with different return types as not compatible,
Arthur Williams <=