https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114731
--- Comment #15 from Alejandro Colomar <alx at kernel dot org> --- (In reply to uecker from comment #13) > A couple of comments: > > In principle, those warnings are not false positives. The design of _Generic > requires that the non-taken branches are valid in C, so some warnings are > required by the C standard. We can tweak warnings (which we already did for > some), but I do not think it is possible to solve all issues in this wa. I showed you an example program in comment #12 that is an evidence that either there's no requirement by ISO C that this results in a diagnostic, or maybe it's required by GCC is already violating the standard here. I'm repeating it here: $ cat constraint.c void f(int *); int main(void) { unsigned u; f(&u); } $ cc constraint.c -S $ > > There are different ways to work around this: > > One can work around using explicit casts and/or temporary values so that the > code of all branches is always valid. It's too error prone. > It may be helpful to flatten multi-level _Generic to one level by matching > an artificial function pointer type: > > #define foo(a, b) _Generic((void(*)(typeof(a), typeof(b)))0, void(*)(int, > int): ...) The thing is that the intermediate macros are also an intended API, so I need to either call it using two levels of macros, or reimplement it in the caller. This is also repetitive and error-prone, just like the casts.