Liste des Groupes | Revenir à cl c |
On 09/07/2024 11:52, Tim Rentsch wrote:
>Thiago Adams <thiago.adams@gmail.com> writes:>
>On 09/07/2024 08:32, Tim Rentsch wrote:>
>Any use of '\0' almost always strikes me as an affectation. It's>
like people want to somehow pretend that it's not the same as
just 0.
I like to pretend
>
'\0' is not int
2 > 1 is not int
etc
>
I know it is int, but I think this needs a redesign in C.
I strongly encourage you not to do that. Based on past
experience most of your ideas for improvements make
things worse rather than better.
It is only for static analysis.
>
For instance:
>
>
enum E {Z = 0};
>
int main()
{
int * p;
p = '\0';
p = false;
p = Z;
}
>
clang has 3 warnings for this code.
>
https://godbolt.org/z/56fn5PT4h
>
Especially for p = Z and p = '\0' we have value 0 of type int, but the
compiler is not blind for the other characteristics.
Les messages affichés proviennent d'usenet.