From c5144966742c1586b10a73fa833a660049d3ea0f Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 25 Nov 2019 19:50:38 +0000 Subject: [PATCH] re PR fortran/92629 (internal compiler error: in convert_mpz_to_unsigned, at fortran/simplify.c:173) 2019-11-25 Harald Anlauf PR fortran/92629 * simplify.c (convert_mpz_to_unsigned): Skip assert for argument range when -fno-range-check is specified. PR fortran/92629 * gfortran.dg/pr92629.f90: New testcase. From-SVN: r278699 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/simplify.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr92629.f90 | 11 +++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr92629.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 95e22137bca..71aacd25caa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-11-25 Harald Anlauf + + PR fortran/92629 + * simplify.c (convert_mpz_to_unsigned): Skip assert for argument + range when -fno-range-check is specified. + 2019-11-25 Mark Eggleston Jim MacArthur diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index b48bf014121..b02c549ecff 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -169,8 +169,10 @@ convert_mpz_to_unsigned (mpz_t x, int bitsize) } else { - /* Confirm that no bits above the signed range are set. */ - gcc_assert (mpz_scan1 (x, bitsize-1) == ULONG_MAX); + /* Confirm that no bits above the signed range are set if we + are doing range checking. */ + if (flag_range_check != 0) + gcc_assert (mpz_scan1 (x, bitsize-1) == ULONG_MAX); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0eead3eb769..fb8fd9d3a87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-25 Harald Anlauf + + PR fortran/92629 + * gfortran.dg/pr92629.f90: New testcase. + 2019-11-25 Paolo Carlini * g++.dg/diagnostic/base-operand-non-pointer-1.C: New. diff --git a/gcc/testsuite/gfortran.dg/pr92629.f90 b/gcc/testsuite/gfortran.dg/pr92629.f90 new file mode 100644 index 00000000000..5c2267ca6f1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr92629.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! { dg-options "-fno-range-check" } +! +! Test the fix for PR92629. +program bge_tests + if (bge (huge (1_1), 128_1)) stop 1 + if (bge ( 128_1 , 255_1)) stop 2 + if (bge (huge (1_2), 32768_2)) stop 3 + if (bge (huge (1_4), 2147483648_4)) stop 4 + if (bge (huge (1_8), 9223372036854775808_8)) stop 5 +end program -- 2.30.2