From 4239975bc627640e75174dae4818482c32225f5e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 27 Jun 2023 17:21:20 -0400 Subject: [PATCH 82/98] FIXME: add gcc/testsuite/c-c++-common/analyzer/strncat-1.c --- .../c-c++-common/analyzer/strncat-1.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/analyzer/strncat-1.c diff --git a/gcc/testsuite/c-c++-common/analyzer/strncat-1.c b/gcc/testsuite/c-c++-common/analyzer/strncat-1.c new file mode 100644 index 000000000000..3db9383bfd72 --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/strncat-1.c @@ -0,0 +1,18 @@ +/* See e.g. https://en.cppreference.com/w/c/string/byte/strncat */ + +extern char *strncat (char *dest, const char *src, size_t count); + +extern char * +test_passthrough (char *dest, const char *src, size_t count) +{ + return strncat (dest, src, count); +} + +/* TODO: + "Appends at most count characters from the character array pointed to by src, stopping if the null character is found, to the end of the null-terminated byte string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The terminating null character is always appended in the end (so the maximum number of bytes the function may write is count+1)." + "The behavior is undefined if the destination array does not have enough space for the contents of both dest and the first count characters of src, plus the terminating null character. The behavior is undefined if the source and destination objects overlap. The behavior is undefined if either dest is not a pointer to a null-terminated byte string or src is not a pointer to a character array," + + "1) returns a copy of dest" + + "Because strncat needs to seek to the end of dest on each call, it is inefficient to concatenate many strings into one using strncat." +*/ -- 2.49.0