diff options
Diffstat (limited to 'src/stdlib/lldiv.c')
| -rw-r--r-- | src/stdlib/lldiv.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stdlib/lldiv.c b/src/stdlib/lldiv.c index 6a8e6fd5..42a5cab6 100644 --- a/src/stdlib/lldiv.c +++ b/src/stdlib/lldiv.c @@ -1,3 +1,4 @@ +#include <limits.h> #include <stdlib.h> #include "_stdlib.h" @@ -6,6 +7,9 @@ lldiv_t lldiv(long long int numer, long long int denom) { SIGNAL_SAFE(0); + if ((denom == 0) || (numer == LLONG_MIN && denom == -1)) { + UNDEFINED("In call to lldiv(): The result of %lld / %lld is not representable as a long long int", numer, denom); + } lldiv_t d; d.quot = numer / denom; @@ -13,6 +17,8 @@ lldiv_t lldiv(long long int numer, long long int denom) return d; } +CHECK_2(lldiv_t, {0}, lldiv, long long int, long long int) + /*** computes both the quotient and remainder of ARGUMENT(numer) divided by ARGUMENT(denom). |
