summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/tests/testsuite.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/replace/tests/testsuite.c b/lib/replace/tests/testsuite.c
index ce344d6549e..b4b038af8c7 100644
--- a/lib/replace/tests/testsuite.c
+++ b/lib/replace/tests/testsuite.c
@@ -283,6 +283,15 @@ static int test_strndup(void)
return false;
}
+#ifdef __GNUC__
+# if __GNUC__ < 11
+ /*
+ * This code will not compile with gcc11 -O3 anymore.
+ *
+ * error: ‘strndup’ specified bound 10 exceeds source size 4 [-Werror=stringop-overread]
+ * x = strndup("bla", 10);
+ * ^~~~~~~~~~~~~~~~~~
+ */
x = strndup("bla", 10);
cmp = strcmp(x, "bla");
free(x);
@@ -290,6 +299,8 @@ static int test_strndup(void)
printf("failure: strndup [\ninvalid\n]\n");
return false;
}
+# endif
+#endif /* __GNUC__ */
printf("success: strndup\n");
return true;