summaryrefslogtreecommitdiff
path: root/test/integration/aligned_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/aligned_alloc.c')
-rw-r--r--test/integration/aligned_alloc.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/integration/aligned_alloc.c b/test/integration/aligned_alloc.c
index 536b67ea..4375b172 100644
--- a/test/integration/aligned_alloc.c
+++ b/test/integration/aligned_alloc.c
@@ -34,6 +34,17 @@ TEST_BEGIN(test_alignment_errors) {
}
TEST_END
+
+/*
+ * GCC "-Walloc-size-larger-than" warning detects when one of the memory
+ * allocation functions is called with a size larger than the maximum size that
+ * they support. Here we want to explicitly test that the allocation functions
+ * do indeed fail properly when this is the case, which triggers the warning.
+ * Therefore we disable the warning for these tests.
+ */
+JEMALLOC_DIAGNOSTIC_PUSH
+JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
+
TEST_BEGIN(test_oom_errors) {
size_t alignment, size;
void *p;
@@ -78,6 +89,9 @@ TEST_BEGIN(test_oom_errors) {
}
TEST_END
+/* Re-enable the "-Walloc-size-larger-than=" warning */
+JEMALLOC_DIAGNOSTIC_POP
+
TEST_BEGIN(test_alignment_and_size) {
#define NITER 4
size_t alignment, size, total;
@@ -124,10 +138,20 @@ TEST_BEGIN(test_alignment_and_size) {
}
TEST_END
+TEST_BEGIN(test_zero_alloc) {
+ void *res = aligned_alloc(8, 0);
+ assert(res);
+ size_t usable = malloc_usable_size(res);
+ assert(usable > 0);
+ free(res);
+}
+TEST_END
+
int
main(void) {
return test(
test_alignment_errors,
test_oom_errors,
- test_alignment_and_size);
+ test_alignment_and_size,
+ test_zero_alloc);
}