<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122517>122517</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[TySan] False positive related to structs in structs?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
seanm
</td>
</tr>
</table>
<pre>
Maybe I'm just not using it right, or not understanding something, but OTOH TySan is new, and thus probably a bit buggy... I used creduce to create a C test case showing, I think, a false positive.
```C
typedef struct {
int len;
char *list;
} str_list;
typedef struct {
str_list infiles;
char command;
} nt_opts;
int add_string(str_list *slist) {
(void)(slist->list);
}
int process_opts(nt_opts *opts) {
add_string(&opts->infiles);
}
void free_opts_mem(nt_opts *nopt) {
(void)(nopt->infiles.list); // •••TySan warns here•••
}
void main(int argc, char *argv[]) {
nt_opts opts;
int rv = process_opts(&opts);
free_opts_mem(&opts);
}
```
then I run:
`(xcrun /Users/sean/llvm/llvm-install/bin/clang -w -g -fsanitize=type test.c && ./a.out)`
and I get:
```
==4848==ERROR: TypeSanitizer: type-aliasing-violation on address 0x00016cfc71f0 (pc 0x000102e3b690 bp 0x00016cfc6ea0 sp 0x00016cfc6620 tid 24776816)
READ of size 8 at 0x00016cfc71f0 with type p1 omnipotent char (in <anonymous type> at offset 8) accesses an existing object of type p1 omnipotent char (in <anonymous type> at offset 8)
#0 0x000102e3b68c in free_opts_mem test.c:20
```
Aside:
- what is an "omnipotent char"?
- what is "type p1" referring to?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVUFvqzoT_TWTzSiRGRIgiyy4TaOvi0-VevvWlYEBfB_YyDZJc3_9kwlpmlbvbp6EVNc-OXNmfGYsnVONZt7B5gds9gs5-tbYnWOp-0VhqvPu__JcMD4BpT3-Gp1HbTyOTukGlUermtYDPaCxlwNdsXVe6ioAnOnZt0o3AVGMHp9fn_-Hr-efUqNyqP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