Skip to content

Commit 15f15ee

Browse files
committed
fix compile error on MSVC
(cherry picked from commit c5cb0c6)
1 parent f0421ba commit 15f15ee

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

demo/test.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,29 +626,34 @@ static int test_mp_invmod(void)
626626
}
627627

628628
#if defined(MP_HAS_SET_DOUBLE)
629+
630+
#ifdef _MSC_VER
631+
#pragma warning(push)
632+
#pragma warning(disable: 4723) /* potential divide by 0 */
633+
#endif
629634
static int test_mp_set_double(void)
630635
{
631636
int i;
637+
double dbl_zero = 0.0;
632638

633639
mp_int a, b;
634640
if (mp_init_multi(&a, &b, NULL)!= MP_OKAY) {
635641
return EXIT_FAILURE;
636642
}
637-
638643
/* test mp_get_double/mp_set_double */
639-
if (mp_set_double(&a, +1.0/0.0) != MP_VAL) {
644+
if (mp_set_double(&a, +1.0/dbl_zero) != MP_VAL) {
640645
printf("\nmp_set_double should return MP_VAL for +inf");
641646
goto LBL_ERR;
642647
}
643-
if (mp_set_double(&a, -1.0/0.0) != MP_VAL) {
648+
if (mp_set_double(&a, -1.0/dbl_zero) != MP_VAL) {
644649
printf("\nmp_set_double should return MP_VAL for -inf");
645650
goto LBL_ERR;
646651
}
647-
if (mp_set_double(&a, +0.0/0.0) != MP_VAL) {
652+
if (mp_set_double(&a, +0.0/dbl_zero) != MP_VAL) {
648653
printf("\nmp_set_double should return MP_VAL for NaN");
649654
goto LBL_ERR;
650655
}
651-
if (mp_set_double(&a, -0.0/0.0) != MP_VAL) {
656+
if (mp_set_double(&a, -0.0/dbl_zero) != MP_VAL) {
652657
printf("\nmp_set_double should return MP_VAL for NaN");
653658
goto LBL_ERR;
654659
}
@@ -681,6 +686,9 @@ static int test_mp_set_double(void)
681686
return EXIT_FAILURE;
682687

683688
}
689+
#ifdef _MSC_VER
690+
#pragma warning(pop)
691+
#endif
684692
#endif
685693

686694
static int test_mp_get_u32(void)

0 commit comments

Comments
 (0)