Skip to content

Commit a773042

Browse files
authored
Merge pull request #20407 from jketema/dyn-too-many
C++: Add `cpp/uninitialized-local` test
2 parents fd5b5ba + 352610d commit a773042

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
struct S {
2+
int a;
3+
int b;
4+
int c;
5+
unsigned long *d;
6+
7+
union {
8+
struct {
9+
const char *e;
10+
int f;
11+
S *g;
12+
const char *h;
13+
int i;
14+
bool j;
15+
bool k;
16+
const char *l;
17+
char **m;
18+
} n;
19+
20+
struct {
21+
bool o;
22+
bool p;
23+
} q;
24+
} r;
25+
};
26+
27+
int too_many_constants_init(S *s);
28+
29+
char *too_many_constants(const char *h, bool k, int i) {
30+
const char *e = "";
31+
char l[64] = "";
32+
char *m;
33+
34+
S s[] = {
35+
{.a = 0, .c = 0, .d = nullptr, .r = {.n = {.e = e, .f = 1, .g = nullptr, .h = h, .i = i, .j = false, .k = k, .l = l, .m = &m}}},
36+
{.a = 0, .c = 0, .d = nullptr, .r = {.q = {.o = true, .p = true}}}
37+
};
38+
39+
too_many_constants_init(s);
40+
41+
return m; // GOOD - initialized by too_many_constants_init
42+
}

0 commit comments

Comments
 (0)