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

Re: [csmith-dev] 0-width named bitfield

On Tue, Aug 16, 2011 at 7:17 PM, Xuejun Yang <jxyang@cs.utah.edu> wrote:
Nice catch. We intended to output 0-length field as anonymous, but the macro
" CSMITH_BITFIELD" makes it hard to determine whether a bitfield is 0 length
or not at generation time.


a workaround in the meantime is to modify the _CSMITH_BITFIELD macro in runtime/random_inc.h so that it never returns 0 when applied to an argument different from 0. Something like (VERY little tested):

diff --git a/runtime/random_inc.h b/runtime/random_inc.h
index 7559cbd..c037bee 100644
--- a/runtime/random_inc.h
+++ b/runtime/random_inc.h
@@ -102,7 +102,7 @@ char __executed_checks[N_WRAP+1];
 #define INT_BIT (sizeof(int)*CHAR_BIT)
-#define _CSMITH_BITFIELD(x) (((x)>INT_BIT)?((x)%INT_BIT):(x))
+#define _CSMITH_BITFIELD(x) (((x)>INT_BIT)?((((x)%INT_BIT)?((x)%INT_BIT):1)):(x))
 #ifdef TCC