summaryrefslogtreecommitdiff
path: root/src/inttypes
diff options
context:
space:
mode:
Diffstat (limited to 'src/inttypes')
-rw-r--r--src/inttypes/imaxabs.c2
-rw-r--r--src/inttypes/imaxdiv.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/inttypes/imaxabs.c b/src/inttypes/imaxabs.c
index 9a49cfc9..04cb0440 100644
--- a/src/inttypes/imaxabs.c
+++ b/src/inttypes/imaxabs.c
@@ -8,7 +8,7 @@ intmax_t imaxabs(intmax_t j)
SIGNAL_SAFE(0);
if (j == INTMAX_MIN) {
- /* undefined behavior */
+ UNDEFINED("In call to imaxabs(): The absoluate value of INTMAX_MIN is not representable as an intmax_t");
return INTMAX_MIN;
}
diff --git a/src/inttypes/imaxdiv.c b/src/inttypes/imaxdiv.c
index 7600cfab..c007f762 100644
--- a/src/inttypes/imaxdiv.c
+++ b/src/inttypes/imaxdiv.c
@@ -7,6 +7,10 @@ imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
{
SIGNAL_SAFE(0);
+ if ((denom == 0) || (numer == INTMAX_MIN && denom == -1)) {
+ UNDEFINED("In call to imaxdiv(): The result of %jd / %jd is not representable as an intmax_t", numer, denom);
+ }
+
imaxdiv_t r;
r.quot = numer / denom;
r.rem = numer % denom;