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: ahata...@gmail.com
          Reporter: jykni...@google.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to