gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] NUM_STONES macro instead of num_stones


From: Arend Bayer
Subject: Re: [gnugo-devel] NUM_STONES macro instead of num_stones
Date: Mon, 28 Apr 2003 12:11:46 +0200 (CEST)

On Thu, 24 Apr 2003, Teun Burgers wrote:

> In order to make sure array bounds checking can be
> performed on the real_num_stones array, I propose
> to use a macro to implement the offset rather than
> the num_stones pointer.

Similarly, GCC with bounds-checking always complains about illegal
pointer comparisons in gg_sort(), and I think it is correct that the
code is standards-incorrect.
(This is extemely unlikely to cause a bug, and definitely won't do so
for the uses in gnugo.)

Arend


Index: utils/gg_utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/utils/gg_utils.c,v
retrieving revision 1.30
diff -u -p -r1.30 gg_utils.c
--- utils/gg_utils.c    22 Feb 2003 10:54:24 -0000      1.30
+++ utils/gg_utils.c    28 Apr 2003 10:08:27 -0000
@@ -376,6 +376,9 @@ gg_sort(void *base, size_t nel, size_t w
   int gap = nel;
   int swap_made;
   char *end = (char *) base + width * (nel - 1);
+
+  if (nel <= 1)
+    return; /* Avoids invalid pointer comparison below for nel == 0 */
   do {
     char *a, *b;
     swap_made = 0;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]