[llvm-bugs] [Bug 46605] New: -Wcast-align incorrectly warning on aligned type.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 6 09:12:58 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46605
Bug ID: 46605
Summary: -Wcast-align incorrectly warning on aligned type.
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: ahatanak at gmail.com
Reporter: jyknight at google.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
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; }
^~~~~~~~~~
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200706/98235c02/attachment.html>
More information about the llvm-bugs
mailing list