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

            Bug ID: 123815
           Summary: Possible false positive -Wattributes for internal
                    linkage functions marked always_inline
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: diagnostics
          Assignee: dmalcolm at redhat dot com
          Reporter: janschultke at googlemail dot com
  Target Milestone: ---

https://godbolt.org/z/81xP5nb1G

[[gnu::always_inline]]
static void f() {}

<source>:2:13: warning: 'always_inline' function might not be inlinable unless
also declared 'inline' [-Wattributes]
    2 | static void f() {}
      |             ^


Is this warning actually correct? My intuition is that [[gnu::always_inline]]
is meant to warn the user about misuses of the attribute, where they've applied
the attribute to a function that cannot be inlined because its definition is
not visible (in some contexts).

However, it is seemingly nonsensical to trigger the warning for a function with
internal linkage whose body is visible. Why would such a function ever not be
inlinable unless declared inline? The end result is that MANY correct (or
harmless in practice) uses of [[gnu::always_inline]] are being flagged on -Wall
when updating to GCC 15.

Reply via email to