1// RUN: %clangxx -O0 -g %s -o %t && %run %t
2
3// UNSUPPORTED: target={{.*linux.*}}
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8
9void test1() {
10 const char src[] = "abc";
11 char dst[7] = {'x', 'y', 'z', 0};
12 size_t len;
13
14 len = strlcat(dest: dst, src: src, n: sizeof(dst));
15 printf(format: "%s %zu ", dst, len);
16}
17
18void test2() {
19 const char src[] = "abc";
20 char dst[7] = {0};
21 size_t len;
22
23 len = strlcat(dest: dst, src: src, n: sizeof(dst));
24 printf(format: "%s %zu ", dst, len);
25}
26
27void test3() {
28 const char src[] = "abc";
29 char dst[4] = {'x', 'y', 'z', 0};
30 size_t len;
31
32 len = strlcat(dest: dst, src: src, n: sizeof(dst));
33 printf(format: "%s %zu ", dst, len);
34}
35
36void test4() {
37 const char src[] = "";
38 char dst[4] = {'x', 'y', 'z', 0};
39 size_t len;
40
41 len = strlcat(dest: dst, src: src, n: sizeof(dst));
42 printf(format: "%s %zu\n", dst, len);
43}
44
45int main(void) {
46 test1();
47 test2();
48 test3();
49 test4();
50
51 // CHECK: xyzabc 6 abc 3 xyz 3 xyz 3
52
53 return 0;
54}
55

source code of compiler-rt/test/sanitizer_common/TestCases/Posix/strlcat.cpp