https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97100

--- Comment #10 from Konstantin Kharlamov <Hi-Angel at yandex dot ru> ---
(In reply to uecker from comment #9)
> Some warnings are then even required to be standard compliant.

I just searched through the C standard and no warnings seem to be required by
it. The only place where word "warning" is mentioned is in the Annex Ⅰ, which
tilted as "informative" and only serves as an example of where warnings might
be useful.

> x is - according to the C standard - always whatever it is in the controlling
> expression.

With the prev. paragraph in mind, compiler is free to warn or not to about
anything. The only (arguable) limitation is being useful. So nothing holds a
compiler off from considering for the warning purposes the `x` to have
different types on the outside of _Generic() compared to the inside.

> Note that this also does not have to be an identifier, but could be a complex
> expression. So there seems no simply algorithm for a compiler to do the right 
> thing
> in general regarding warnings.

Idk why complexity matters, it's not like `x` is dynamically typed, so no
solving halting problem requried. For me it looks simple: if `x` entered either
branch of _Generic, just consider it to have a type different from what it was
and produce correct warnings 😊

Reply via email to