gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] sign bit bit shift issue


From: Arend Bayer
Subject: [gnugo-devel] sign bit bit shift issue
Date: Sat, 8 Feb 2003 13:52:24 +0100 (CET)

According to the C standard, the patch below fixes a bug. Rotating into
the sign bit of a signed integer is undefined.

Does anyone happen to know whether this is a problem in real world?
(I.e. do there exist platforms where (1 << 31 == 0x8000000) does not
hold true?)

Arend


Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.23.2.2
diff -u -p -r1.23.2.2 cache.h
--- engine/cache.h      5 Jan 2003 19:56:59 -0000       1.23.2.2
+++ engine/cache.h      8 Feb 2003 12:50:55 -0000
@@ -87,8 +87,8 @@ typedef struct read_result_t {

 /* Set corresponding parts. */
 #define rr_input_data1(routine, komaster, kom_pos, str1, stackp) \
-       (((((((((komaster) << 10) | (kom_pos)) << 4) \
-         | (routine)) << 10) | (str1)) << 5) | (stackp));
+       ((( (unsigned) (((((((komaster) << 10) | (kom_pos)) << 4) \
+         | (routine)) << 10) | (str1))) << 5) | ((unsigned) stackp));
 #define rr_input_data2(str2) (str2) \

 /* Set input data fields and at the same time set status to open. */





reply via email to

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