From a9309034d275a97956c0c8854e943e25cda57039 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 5 Nov 2024 21:11:02 +0100 Subject: [PATCH 09/23] strncat tests: Verify N3322 functionality. * tests/test-strncat.c (main): Add a zero-size test. --- ChangeLog | 5 +++++ tests/test-strncat.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index b61465d749..15d587da21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-11-05 Bruno Haible + + strncat tests: Verify N3322 functionality. + * tests/test-strncat.c (main): Add a zero-size test. + 2024-11-05 Bruno Haible strndup tests: Verify N3322 functionality. diff --git a/tests/test-strncat.c b/tests/test-strncat.c index 0ee5089e58..c4668d95b4 100644 --- a/tests/test-strncat.c +++ b/tests/test-strncat.c @@ -58,5 +58,21 @@ main () check (input, SIZEOF (input)); } + int volatile value; + + /* Test zero-length operations on NULL pointers, allowed by + . */ + +#if 0 /* I think this is invalid, per ISO C 23 ยง 7.26.3.2. */ + value = (strncat (NULL, "x", 0) == NULL); + ASSERT (value); +#endif + + { + char y[1]; + value = (strncat (y, NULL, 0) == y); + ASSERT (value); + } + return test_exit_status; } -- 2.34.1