This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: signed vs unsigned comparison warnings
- To: kenner at vlsi1 dot ultra dot nyu dot edu
- Subject: Re: signed vs unsigned comparison warnings
- From: Marc Espie <espie at quatramaran dot ens dot fr>
- Date: Tue, 20 Jun 2000 21:15:28 +0200
- Cc: gcc at gcc dot gnu dot org
- Organization: Ecole Normale Superieure (quatramaran)
In article <10006201642.AA01025@vlsi1.ultra.nyu.edu> you write:
> I'm not aware of a single bug fixed by the boatloads of changes to
> eliminate signed vs unsigned comparison warnings.
>
>I think I remember one ...
>
> As a result, I think it is in our best interest to not try and "fix"
> such warnings and instead turn off the warnings on the command line.
> We've got bigger fish to fry IMHO.
>
>Yes and no. These warnings tend to produce a more "strictly typed"
>program and that's a good thing from a cleanliness point of view. So
>there is *some* advantage, though I agree it's not very large.
>
In my experience, using unsigned in C is almost always a mistake.
The way conversion works, it does create all sorts of nasty problems
that don't exist with signed arithmetic, and the extra bit of precision
is VERY rarely useful.
The only justifiable instance of unsigned I know is for modular arithmetic,
where you know what you are doing and are really interested in true
arithmetic modulo 2^32 (or larger, or smaller).