-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
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 analyzer
Description
Testcase ( https://godbolt.org/z/o1b83cEbG )
#include <cstdint>
using UnalignedType [[gnu::aligned(1)]] = struct
{
uint32_t x;
};
alignas(4) UnalignedType alignedVariable{};
void f(UnalignedType)
{}
static_assert(alignof(UnalignedType) == 1);
static_assert(alignof(alignedVariable) == 4);
int main()
{
f(alignedVariable);
}
The diagnostic reported is
passing 1-byte aligned argument to 4-byte aligned parameter
'this'of'UnalignedType'may result in an unaligned pointer access[-Walign-mismatch]
18 | f(alignedVariable);
| ^
However, the argument alignedVariable is 4-byte aligned, and I would expect UnalignedType to be a one-byte aligned parameter; the reported alignments seem to be reversed
meator
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 analyzer