Re: Comparing singed to unsinged warning
- From: Al Balmer <albalmer@xxxxxxx>
- Date: Wed, 22 Aug 2007 23:18:34 GMT
On Thu, 23 Aug 2007 01:09:39 +0200 (CEST), Nevil Lesdog <nl@xxxxxxxxx>
wrote:
What do you think is the best way to handle a compiler warning about
comparing an unsinged value to a singed value? Cast to silence it?
Disable that warning altogether? Or just live with it?
Look at the code and make darned sure you understand why the warning
occurred, and why it was necessary to compare things of two different
type. Then, if you still think it was the right thing to do, use a
cast, which will at least indicate that you did it on purpose.
On one hand, the warning *could* be useful. Most of the time I get it in
cases where I know the comparison is safe, but it's not hard to imagine
that this won't always be the case. This makes disabling it undesirable.
Casting is a workable solution, but I worry that changes in the code
later could introduce errors that go undetected due to the cast. And I
think we all hate not having a "clean" compile (if only because having a
bunch of warnings that you expected makes it more difficult to spot the
ones you didn't expect).
What is your opinion?
My opinion is that there's a very good chance that the code could be
better written.
--
Al Balmer
Sun City, AZ
.
- References:
- Comparing singed to unsinged warning
- From: Nevil Lesdog
- Comparing singed to unsinged warning
- Prev by Date: Function prototypes
- Next by Date: defining variable
- Previous by thread: Comparing singed to unsinged warning
- Next by thread: Re: Comparing singed to unsinged warning
- Index(es):
Relevant Pages
|