|
From: | grischka |
Subject: | Re: [Tinycc-devel] Patch: Treat func pointers with different return types as not compatible |
Date: | Tue, 24 Nov 2020 11:49:09 +0100 |
User-agent: | Thunderbird 2.0.0.23 (Windows/20090812) |
Arthur Williams wrote:
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.
Yes, thanks for that. Meanwhile I came up with another idea to solve type problems with internally called helper functions which is not to assign to them a C type at all. (Otherwise some more functions would have been affected too, such as memset or alloca) -- gr
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)); }
[Prev in Thread] | Current Thread | [Next in Thread] |