Skip to content

Commit 2d3262a

Browse files
authored
Merge pull request #442 from libtom/bug-min-prec
MP_MIN_PREC too small, test with MP_PREC=MP_MIN_PREC
2 parents 820f4bb + 2bbdbd0 commit 2d3262a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ matrix:
145145
- env: SANITIZER=1 CONV_WARNINGS=relaxed BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
146146
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
147147
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --c89 --with-m64 --with-travis-valgrind'
148+
- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind --cflags=-DMP_PREC=MP_MIN_PREC'
148149
- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-travis-valgrind'
149150
addons:
150151
apt:

tommath_private.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ MP_STATIC_ASSERT(correct_word_size, sizeof(mp_word) == (2u * sizeof(mp_digit)))
177177
# endif
178178
#endif
179179

180-
/* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC */
181-
#define MP_MIN_PREC ((((int)MP_SIZEOF_BITS(long long) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
182-
180+
/* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC
181+
* - Must be at least 3 for s_mp_div_school.
182+
* - Must be large enough such that uint64_t can be stored in mp_int without growing
183+
*/
184+
#define MP_MIN_PREC MP_MAX(3, (((int)MP_SIZEOF_BITS(long long) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
183185
MP_STATIC_ASSERT(prec_geq_min_prec, MP_PREC >= MP_MIN_PREC)
184186

185187
/* random number source */

0 commit comments

Comments
 (0)