https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108262
Bug ID: 108262
Summary: Spurious [Wignored-attributes] on vector intrinsic
types, even in constexpr contexts
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ian at geometrian dot com
Target Milestone: ---
We've been running into a peculiar issue where [Wignored-attributes] is
triggering on apparently benign uses of vector intrinsic types. Consider the
following example:
#include <xmmintrin.h>
template<class T> struct Wrap { T val; };
using WrapT = Wrap<__m128>;
This will produce (compiled with no arguments, which is a bit surprising; one
might expect "-std=c++17 -Wignored-attributes"):
<source>:3:26: warning: ignoring attributes on template argument '__m128'
[-Wignored-attributes]
3 | using WrapT = Wrap<__m128>;
| ^
You can get a similar error with another test case:
#include <immintrin.h>
#include <type_traits>
constexpr inline bool b = std::is_same_v< int, __m128 >;
Clang, MSVC, and ICC all compile these examples cleanly, but GCC produces the
warning.
I believe the warning is erroneous. `__m128`, etc. are of course aligned,
which I assume is the "attribute" to which GCC is referring (bonus bug: it
would be helpful if this were specified!), however the attribute is not being
ignored in any way. In the first example, the alignment of `Wrap` inherits
from its members (easily confirmable with
`static_assert(alignof(WrapT)==16);`). In the second example, we're just using
`__m128` as a template argument, in the standard library no less.
The warning can be silenced with "-Wno-ignored-attributes".
This issue seems to have existed for a long time; the first example is a
distillation of https://stackoverflow.com/q/41676311/, and I have tested it as
reproducing all the way back to GCC 6.1.
Version: 13.0.0 20230101
System + Options: x86_64-linux-gnu