This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wconversion and signedness
Alexandre Oliva <oliva@dcc.unicamp.br> writes:
> On Jun 23, 1999, Alexandre Duret-Lutz <duret_g@epita.fr> wrote:
>
> > Shouldn't egcs complain with -Wconversion on the following snippet :
>
> > unsigned i = 2;
> > unsigned j = -i;
>
> Nope. Unary minus, when applied to an unsigned integral value i,
> means unsigned `2^n - i', where `n' is the number of bits in the
> unsigned type.
I was fairly sure that this was (roughly) 2^n + 1 - i
... but really you should substitute 2^n with UINT_MAX or ULONG_MAX
etc.
--
James Antill -- james@and.org
If you go to the Third World and find 100 people who have never tasted ketchup
before, you find out two things: one is that people don't actually like tomato
ketchup, the other is that they dislike all ketchups equally. -- Rob Young.