<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Bounds sanitizer instruments [0] array inside a union"
   href="https://bugs.llvm.org/show_bug.cgi?id=45030">45030</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bounds sanitizer instruments [0] array inside a union
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lenaptr@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>It looks like bounds sanitizer treats unions as structs, and all flex arrays
except for the last one are being checked (while none of them should):

```
#include <stdlib.h>

typedef union {
    char foo[0];
    void *bar[0];
    void *buz[0];
} flexi;

void repro(int i) {
    flexi *a = (flexi*) malloc(50);
    a->foo[i] = 0;  // this will be instrumented
    a->bar[i] = 0;  // this will be instrumented
    a->buz[i] = 0;  // this won't be instrumented
    free(a);
}
```

Compile with `-fsanitize=bounds`

->bar and ->buz are semantically the same, but only one of them gets flex array
exception. ->foo also shouldn't be instrumented.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>