Skip to content

Commit 91e15a9

Browse files
authoredJul 11, 2024
Make lbool explicitly signed (lsils#650)
This avoids issues due to some platforms making `char` signed and others unsigned. In particular, on platforms where `char` is unsigned, https://github.com/lsils/mockturtle/blob/50ffa108484ba65b44eee4a713832b7ee821d6d8/lib/bill/bill/sat/interface/abc_bsat2.hpp#L156 promotes an `lbool` to `int` and compares to -1 ... but promoting `(unsigned char)-1` to `int` produces 255.`
1 parent 50ffa10 commit 91e15a9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎lib/abcsat/abc/satVec.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ static inline void vecp_remove(vecp* v, void* e)
130130
typedef int lit;
131131
typedef int cla;
132132

133-
typedef char lbool;
133+
// Explicitly make it signed so promotion-to-int behavior doesn't vary
134+
// across platforms that define signedness of char differently.
135+
typedef signed char lbool;
134136

135137
// CryptoMinisat defines it's own var_Undef values.
136138
// When it's included we prefer the ABC version instead.

‎lib/bill/bill/sat/solver/abc/satVec.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ static inline void vecp_remove(vecp* v, void* e)
130130
typedef int lit;
131131
typedef int cla;
132132

133-
typedef char lbool;
133+
// Explicitly make it signed so promotion-to-int behavior doesn't vary
134+
// across platforms that define signedness of char differently.
135+
typedef signed char lbool;
134136

135137
// CryptoMinisat defines it's own var_Undef values.
136138
// When it's included we prefer the ABC version instead.

0 commit comments

Comments
 (0)
Please sign in to comment.