This is the mail archive of the
mailing list for the GCC project.
Re: -Wconversion and signedness
Alexandre Oliva <email@example.com> writes:
> On Jun 23, 1999, Alexandre Duret-Lutz <firstname.lastname@example.org> 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
James Antill -- email@example.com
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.