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

            Bug ID: 121669
           Summary: -Wpsabi warnings should be suppressed for
                    always_inline functions
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mkretz at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-*-*

Test case (https://compiler-explorer.com/z/GzYe7qhTc):

using V [[gnu::vector_size(32)]] = int;

[[gnu::always_inline]]
inline V
f(V a)
{ return a; }

void g()
{
  V x = {};
  x = f(x);
}

Compiled with `-march=x86-64-v2 -Wpsabi` this code is diagnosed with:

<source>:5:6: warning: AVX vector return without AVX enabled changes the ABI
[-Wpsabi]
    5 | f(V a)
      |      ^
<source>:5:1: note: the ABI for passing parameters with 32-byte alignment has
changed in GCC 4.6
    5 | f(V a)
      | ^

But that's a bogus warning because the function f is *always* inlined and any
potential ABI incompatibilities are therefore never going to matter. The
warning should, IMHO, be conditional on whether the function in question is
always_inline.

This issue is coming up in the std::simd internals all over the place, forcing
the use of -Wno-psabi. (One reason for using always_inline in std::simd is
exactly to avoid ABI issues.)

I'm only familiar with this warning coming up on x86. I don't know how relevant
this issue is for other targets.

Reply via email to