Branch: refs/heads/main
Revision: a9ade7b
Author: lydia-duncan
Link: Unavailable
Log Message:
Merge pull request #19368 from lydia-duncan/divisionCheck
Add checks for division by 0 to the bigint division methods
[reviewed by @vasslitvinov]
These checks are controlled by the --div-by-zero-checks
flag. Now the bigint
division methods match the behavior of regular integer division operators,
generating a halt when checking for division by 0 and when such checks are
turned off, relying on the GMP implementation's behavior.
Resolves #18007
Adds tests that check:
- divexact
- divQ
- divR
- divQR
- / operator
- /= operator
These tests will only run with --checks
and --div-by-zero-checks
. I could
have chosen to skip the tests when --no-check
or --fast
are in the compopts,
but I think this makes more sense.
Does not check:
- isDivisible (the function explicitly calls out that division by 0 is okay)
- isDivisibleBy2Pow (will not result in a division by 0)
- divQ2Exp (will not result in a division by 0)
- divR2Exp (will not result in a division by 0)
Passed a full paratest with futures
Modified Files:
A test/library/standard/BigInteger/divQByZero.chpl
A test/library/standard/BigInteger/divQByZero.compopts
A test/library/standard/BigInteger/divQByZero.good
A test/library/standard/BigInteger/divQRByZero.chpl
A test/library/standard/BigInteger/divQRByZero.compopts
A test/library/standard/BigInteger/divQRByZero.good
A test/library/standard/BigInteger/divRByZero.chpl
A test/library/standard/BigInteger/divRByZero.compopts
A test/library/standard/BigInteger/divRByZero.good
A test/library/standard/BigInteger/divexactByZero.chpl
A test/library/standard/BigInteger/divexactByZero.compopts
A test/library/standard/BigInteger/divexactByZero.good
A test/library/standard/BigInteger/divideByZero.chpl
A test/library/standard/BigInteger/divideByZero.compopts
A test/library/standard/BigInteger/divideByZero.good
A test/library/standard/BigInteger/divideEqualsByZero.chpl
A test/library/standard/BigInteger/divideEqualsByZero.compopts
A test/library/standard/BigInteger/divideEqualsByZero.good
M modules/standard/BigInteger.chpl
Compare: https://github.com/chapel-lang/chapel/compare/a79144c35a5e...a9ade7ba6466