public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108262] New: Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts
@ 2023-01-01 21:21 ian at geometrian dot com
  2023-01-01 21:23 ` [Bug c++/108262] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ian at geometrian dot com @ 2023-01-01 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/108262] Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts
  2023-01-01 21:21 [Bug c++/108262] New: Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts ian at geometrian dot com
@ 2023-01-01 21:23 ` pinskia at gcc dot gnu.org
  2023-01-01 21:26 ` pinskia at gcc dot gnu.org
  2023-01-01 21:30 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-01 21:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108262

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The attribute that is being complained about is may_alias.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/108262] Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts
  2023-01-01 21:21 [Bug c++/108262] New: Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts ian at geometrian dot com
  2023-01-01 21:23 ` [Bug c++/108262] " pinskia at gcc dot gnu.org
@ 2023-01-01 21:26 ` pinskia at gcc dot gnu.org
  2023-01-01 21:30 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-01 21:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108262

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 84415

*** This bug has been marked as a duplicate of bug 84415 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/108262] Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts
  2023-01-01 21:21 [Bug c++/108262] New: Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts ian at geometrian dot com
  2023-01-01 21:23 ` [Bug c++/108262] " pinskia at gcc dot gnu.org
  2023-01-01 21:26 ` pinskia at gcc dot gnu.org
@ 2023-01-01 21:30 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-01 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108262

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note even though clang might be accepting this without warning, it most likely
not producing correct results. See PR 97222 for the full analysis and the
referenced clang bug and even then requires an ABI change...

*** This bug has been marked as a duplicate of bug 97222 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-01 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-01 21:21 [Bug c++/108262] New: Spurious [Wignored-attributes] on vector intrinsic types, even in constexpr contexts ian at geometrian dot com
2023-01-01 21:23 ` [Bug c++/108262] " pinskia at gcc dot gnu.org
2023-01-01 21:26 ` pinskia at gcc dot gnu.org
2023-01-01 21:30 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).