<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 - -Wcast-align incorrectly warning on aligned type."
   href="https://bugs.llvm.org/show_bug.cgi?id=46605">46605</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wcast-align incorrectly warning on aligned type.
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>ahatanak@gmail.com
          </td>
        </tr>

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This seems to be a regression from 854f5f332af4640d9425e9a94442629e4f5a3f98
("[Sema] Teach -Wcast-align to compute an accurate alignment using the
alignment information on VarDecls in more cases.")


Running `clang -Wcast-align test.cc` on the following program:

```
class Foo {
  long x;
};

struct Bar {
  alignas(Foo) char buf[sizeof(Foo)];
  Foo* getFoo() { return (Foo*)&buf; }
};
```

results in an incorrect warning, despite that "buf" is actually correctly
8-byte aligned:

test.cc:7:26: warning: cast from 'char (*)[8]' to 'Foo *' increases required
alignment from 1 to 8 [-Wcast-align]
  Foo* getFoo() { return (Foo*)&buf; }
                         ^~~~~~~~~~</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>