https://llvm.org/bugs/show_bug.cgi?id=31050
Bug ID: 31050 Summary: False positive warning of -Waddress-of-packed-member Product: clang Version: unspecified Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: yunl...@chromium.org CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified #include <stdio.h> typedef struct __attribute__ ((packed, aligned(4))) { short a; short b; int c; } A; int main() { A s; s.c = 0; int* ptr = &s.c; printf("%d", *ptr); return 0; } Struct A is explictly requested to be aligned to 4 bytes. Therefore, A.c is also aligned to 4 bytes. However clang incorrectly complains: taking address of packed member 'c' of class or structure 'A' may result in an unaligned pointer value [-Waddress-of-packed-member] int* ptr = &s.c; Thanks, -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs