constant signed/unsigned comparison warning
Erik Corry
ec@sign-tronic.dk
Thu Sep 25 04:01:00 GMT 1997
> Hi,
>
> Erik Corry wrote:
> >
> >> Apparently, especially ugly for people with other compilers who actually
> >> might run into problems when GCC does something like this.
> >
> >Why does this cause problems? People with other compilers can
> >just disable signed/unsigned warnings entirely. Gcc users get
> >just the warnings that (might) matter, and none of the others.
> >Gcc has always been great at warnings.
>
> The problem has been beaten to death, actually, but what the hell...
>
> int i = -15;
try:
ssize_t i = function();
> if(i < sizeof(i)) printf("Neat") else printf("You forgot something");
No, my proposal was that i should have type ssize_t, and that
ssize_t should have the special property that signed/unsigned
warnings were suppressed for it, even if you use -Wall. This
way, everything 'just works', even for sizeofs that are greater
than 1<<31. Normal conversions are still applied, only the warning
is supressed.
You can argue that it is too difficult to do in gcc, but I don't
think you can argue that it generates incorrect output for correct
code.
--
Erik Corry ec@sign-tronic.dk - I do not speak for Sign-Tronic A/S
More information about the Gcc
mailing list