Re: bitvectors issues?

From: John Whitla (cjw7@gte.net)
Date: 07/10/02


> After changing bitvector_t to unsigned long long int:
>
> gcc -g -O2 -Wall    -c -o genzon.o genzon.c
> genzon.c: In function `create_new_zone':
> genzon.c:81: warning: comparison is always false due to limited range of
> data type
> genzon.c: In function `save_zone':
> genzon.c:345: warning: comparison is always false due to limited range of
> data type
>
> some relevant code:
>   if (vzone_num < 0) {
>     *error = "You can't make negative zones.\r\n";
>     return NOWHERE;
>
> Are these just useless now?  As in, should I junk them?  Or did I do
> something wrong when I changed bitvector_t?

You changed bitvector_t to "unsigned".  Unsigned values start at zero and
count up to the range specified.  Tests for <value> less than zero will
always be false.

This answers why your compiler is spitting out warnings, but it doesn't
answer your larger questions.  The code bit you specified is likely
unnecessary, but the behavior of bitvector_t in general would require
analyzing all instances of its use to be sure that "negative" values are
never necessary/meaningful.  There is no substitute for doing the homework
when it comes to changing data types.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT