1#include <stdlib.h>
2#include <string.h>
3
4struct WithFlexChar {
5 int member;
6 char flexible[];
7};
8
9struct WithFlexSChar {
10 int member;
11 signed char flexible[];
12};
13
14struct WithFlexUChar {
15 int member;
16 unsigned char flexible[];
17};
18
19#define CONTENTS "contents"
20
21int main() {
22 struct WithFlexChar *c =
23 (struct WithFlexChar *)malloc(size: sizeof(int) + sizeof(CONTENTS));
24 c->member = 1;
25 strcpy(dest: c->flexible, CONTENTS);
26
27 struct WithFlexSChar *sc =
28 (struct WithFlexSChar *)malloc(size: sizeof(int) + sizeof(CONTENTS));
29 sc->member = 1;
30 strcpy(dest: (char *)sc->flexible, CONTENTS);
31
32 struct WithFlexUChar *uc =
33 (struct WithFlexUChar *)malloc(size: sizeof(int) + sizeof(CONTENTS));
34 uc->member = 1;
35 strcpy(dest: (char *)uc->flexible, CONTENTS);
36 return 0; // break here
37}
38

source code of lldb/test/API/lang/c/flexible-array-members/main.c