summaryrefslogtreecommitdiff
path: root/src/stdlib/abs.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-02-02 13:22:25 -0500
committerJakob Kaivo <jkk@ung.org>2024-02-02 13:22:25 -0500
commit68467da17d576a17e4ff96c60f581561ac0bbe88 (patch)
treeabd46d060469cd4438634c5c4ff660d2b1771c2c /src/stdlib/abs.c
parent8a620a7c60e5745f5f38aaa1547a66a2d0dc9926 (diff)
check for invalid integer conversions
Diffstat (limited to 'src/stdlib/abs.c')
-rw-r--r--src/stdlib/abs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stdlib/abs.c b/src/stdlib/abs.c
index 74455c59..3cdd2762 100644
--- a/src/stdlib/abs.c
+++ b/src/stdlib/abs.c
@@ -9,12 +9,15 @@ int abs(int j)
SIGNAL_SAFE(0);
if (j == INT_MIN) {
- /* undefined behavior */
+ UNDEFINED("In call to abs(): The absolute value of INT_MIN is not representable as an int");
+ return INT_MIN;
}
return j < 0 ? -j : j;
}
+CHECK_1(int, 0, abs, int)
+
/***
computes the absolute value of ARGUMENT(j).
***/