-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Labels
clang: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 analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not
Description
https://godbolt.org/z/vKxY544zz
typedef struct __attribute__ ((packed)) {
char a;
int element;
} packed_struct_type;
void somefunc (void *a, int b)
{
}
int main (int argc, char **argv)
{
packed_struct_type packed_struct;
somefunc(&packed_struct.element, ({3;}));
somefunc(&packed_struct.element, 3);
}
diagnostic:
<source>:14:15: warning: taking address of packed member 'element' of class or structure 'packed_struct_type' may result in an unaligned pointer value [-Waddress-of-packed-member]
14 | somefunc(&packed_struct.element, ({3;}));
|
See an invalid address-of-packed-member warning here. Passing the pointer to a void* parameter should not cause the warning to show, however see the warning in the case of the statement expression in the function call on line 14.
Metadata
Metadata
Assignees
Labels
clang: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 analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not
Activity
[Sema] Fix false positive warnings for misaligned member access
[Sema] Fix false positive warnings for misaligned member access
[Sema] Fix false positive warnings for misaligned member access (#150025