<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57434>57434</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Deadstore checker giving false positives on function pointers after https://reviews.llvm.org/D126534
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tauchris
</td>
</tr>
</table>
<pre>
Commit [16cb3be62600](https://reviews.llvm.org/rG16cb3be62600621361644ebd15d071c711d6aa86) introduced new true-positive findings in C, but also introduced at least one new **false positive** for function pointers. Here's the failing case: [https://godbolt.org/z/63zzcT8ch](https://godbolt.org/z/63zzcT8ch). Code is also shown here:
```
typedef int (*FNPTR)(int x, int y, int p);
int defaultFn(int x, int y, int p)
{
return x+y+p;
}
int altFn1(int x, int y, int p)
{
return x+y+p;
}
int altFn2(int x, int y, int p)
{
return x+y+p;
}
FNPTR foo(int x)
{
static char* strings[] = {"string1", "string2", "string3"};
FNPTR fp = defaultFn;
if (x < 0) {
fp = altFn1;
}
else if (x == 0) {
fp = altFn2;
}
else {
fp = 0;
}
return fp;
}
```
In this code, the assignment `FNPTR fp = defaultFn;` triggers the checker warning. I believe this is a false positive, because a function pointer does not have storage.
This change was reviewed here: https://reviews.llvm.org/D126534
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VE1zmzAQ_TVw2YkHCRDmwCGxJ20unU4nf0CIBdRi5JFE0uTXd4VJ7DhfvcQDGC27b9-utK82zUO1Mbud9hDlV0yoOq1RcJEkUb6N-Lr3fu-i9DLi13RZvNN471bDcLdbGdsF07fTIMFZKpjIMqwbljdJwVTBWCOkXIuIl6BHb00zKWxgxHvwdsKLvXHa6zuEVo-NHjtHXrCJ-AbqyYMcnDkNkx4GlM6DGXHGiDiRu2zJD-EJ6mCD1lhop1F5bUb6Riho3QrgO1pyKRz4nrJKPVBWUNIhFRra8LLozjS1GfxS7yPdIn18VLdr1b_Vo4_ceUnZYWMaBO0Opbne3I_QB0aEkGyj5OkpkuWal_5hjw22oRVU8prKu_7x8_YXQdIqGP-GjoWXh6eXffiYXp2CBjOhyGnw1-PHgYeoYgkn2mDRT3YM_lfkerU_Yhfb8yQyJGBfnoF_VYa5uXSAzDHBW3DOS68VqF7acOCct-EA0xGikwFRSjd5c36wUzt4oPds4OeGNBiISHqSYmGyn-GOe3fqottwJP6SxwaSMGYvOIbfEr7symnsc91hgWGIjmjbEPM5IP8E8L3g5P24ZZvad_fnbDpuRpplGilFoxU6GgZbOqe7cYdhYETyfhtFQjqku460YY5TPao_aOFe2pH2hCb2BmocNJJEzUnC6MK54JBaoZIT2eQrzYHGoIPReOglgThvrOxwdVrP7cy-l2OHlNjBQWlJ7xZlgE-FeMu4yNPsABdjxYRg66QQJY-bKm3KtJSx137AaouyCRyOpXb6Lkjgy5ocSexr-QTZhor-l0482aE6E0jt-6leKbOjRYhY_i721vxG5WmpnZvQ0UteZITRV6XMqIIWWZPmrVJtnqYsy1iGaVnKUuXxIGmLXHWYvFhXPOE8WfOSM5blfCVFjWWRMZlSP4pSRFmCOxL-Z8axrWYO9UTjmyWDdv5YTnw4SohP-HLyvbGVl5PqrXbxzLeayf4DC4wj1Q">