<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122954>122954</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [TySan] False positive with global structs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          TheLastRar
      </td>
    </tr>
</table>

<pre>
    This was previously reported in the discourse, since TySan has now been merged I'm reposting it on Github

This is the reduced version from [gbMattN](https://discourse.llvm.org/t/reviving-typesanitizer-a-sanitizer-to-catch-type-based-aliasing-violations/66092/22), the original report used a `std::array<float,2>`

Tysan reports a type violation when arr is in the global scope https://godbolt.org/z/TxeaaY5cc

```C
#include <stdio.h>

struct array_type{
    int inner[1];
};

struct array_type arr;

int main() {
  arr.inner[0] = 5;
  return 0;
}
```

TySan currently reports
```
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x5d14c0846c5c (pc 0x5d14bfeefb4b bp 0x7ffd3e06b7a0 sp 0x7ffd3e06b730 tid 1)
WRITE of size 4 at 0x5d14c0846c5c with type int accesses an existing object of type array_type
    #0 0x5d14bfeefb4a (/app/output.s+0x2ab4a)
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsVF2L6zgM_TXui2hx7aRtHvLQmd4sF_YD5haWfVoUW228pHawnM50fv3i9GPuzC4E7NiWdHR0JGR2R09Ui_JJlLsZjqkLsd539CtyesE4a4O91PvOMbwiwxDp7MLI_QUiDSEmsuA8pI7AOjZhjExCPQM7bwj2lx_ooUMGH16hJfJwongkC9-FWp8mF5ycP4JLEDz84lI3tkJuhdxOIR1PriPZ0ZCFM0V2wcMhhhOI8unY_oYp_S7KnVCbLqWBhd4K1QjVPNAs-v58WoR4FKpJQjU5gbPzx3m6DMToXXLvFOc4_9inMDeYTDc9mbfIZOfYO-Rsdnahx-SCZ6Ga1U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