On 02/23/15 15:00, Richard Sandiford wrote:
The comment for wi::from_mpz says:

/* Returns X converted to TYPE.  If WRAP is true, then out-of-range
    values of VAL will be wrapped; otherwise, they will be set to the
    appropriate minimum or maximum TYPE bound.  */

The problem in PR 63427 was that we didn't actually implement the WRAP
case; we just read the whole thing into a wide_int and hoped that it
was already in range of the target precision.  In the testcase this
resulted in the "len" field being too big for the precision, which
"only" showed up as a failure when ubsan was enabled.  But in more
extreme cases we could walk well beyond the end up of the buffer,
as shown by a segfault in the attached testcase.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
        PR fortran/63427
        * wide-int.cc (wi::from_mpz): Cope with unwrapped values that are
        too big for a wide_int.  Implement missing wrapping operation.

gcc/testsuite/
        PR fortran/63427
        * gfortran.dg/integer_exponentiation_6.F90: New test.
OK.
jeff

Reply via email to