1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma safety enable
void* malloc(unsigned size);
void free(void* ptr);
struct X {
char* name;
};
struct X* F(int i)
{
struct X* p1 = 0;
try
{
if (i == 1)
{
p1 = malloc(sizeof * p1);
while (0){}
}
else if (i == 3)
{
p1 = malloc(sizeof * p1);
}
}
catch
{
}
return p1; //p1.name not initialized
}
#pragma cake diagnostic check "-Wanalyzer-maybe-uninitialized]"
#pragma cake diagnostic check "-Wanalyzer-maybe-uninitialized]"
//We have two error message here, because one is generated when we read p1
//the other one is generated because the returned object may access initialized objects.