[LLVMbugs] [Bug 9219] New: Possible false positive with -Wcast-align and #pragma pack(push, 2)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Feb 14 09:15:43 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=9219
Summary: Possible false positive with -Wcast-align and #pragma
pack(push, 2)
Product: new-bugs
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sean at rogue-research.com
CC: llvmbugs at cs.uiuc.edu
Consider this C code:
--------
#include <CoreServices/CoreServices.h>
int main(void)
{
FSCatalogInfo catalogInfo = {};
FileInfo* fileInfo = (FileInfo*)(&catalogInfo.finderInfo);
(void)fileInfo;
return 0;
}
--------
With -Wcast-align clang says:
test.c:6:23: warning: cast from 'UInt8 (*)[16]' to 'FileInfo *' (aka
'struct FileInfo *')
increases required alignment from 1 to 2 [-Wcast-align]
FileInfo* fileInfo = (FileInfo*)(&catalogInfo.finderInfo);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think this is maybe a false positive, though I'm not sure.
a) The docs for the FSCatalogInfo struct say:
/*
* kFSCatInfoFinderInfo / file type, creator, flags, location.
* Coerce to a File/FolderInfo to use.
*/
UInt8 finderInfo[16];
Implying that the cast should be safe.
b) Files.h starts with #pragma pack(push, 2). I'm thinking maybe clang does
not take that into account.
If clang is indeed correct here, then I'll file a Radar against
CarbonCore/Files.h.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list