-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed as not planned
Closed as not planned
Copy link
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerincompleteIssue not complete (e.g. missing a reproducer, build arguments, etc.)Issue not complete (e.g. missing a reproducer, build arguments, etc.)
Description
| Bugzilla Link | 9219 |
| Version | trunk |
| OS | MacOS X |
| CC | @rjmccall |
Extended Description
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.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerincompleteIssue not complete (e.g. missing a reproducer, build arguments, etc.)Issue not complete (e.g. missing a reproducer, build arguments, etc.)