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

            Bug ID: 107931
           Summary: [12 Regression] -Od causes always_inline to fail
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at xenu dot pl
  Target Milestone: ---

The error below occurs only with -Od. The code is accepted if one of
-O0, -O1, -O2, -O3 or -Os is used instead.

This happens with GCC 12.1 and 12.2, it doesn't with 11.3.

$ cat code.c
typedef int (*fptr_t) (void);

static inline int __attribute__((always_inline)) fun4(void);

static inline void
__attribute__((always_inline))
fun3(fptr_t p)
{
    p();
}

static void
fun2(void)
{
    fun3(fun4);
}

void
fun1(void)
{
    fun2();
}

static inline int
__attribute__((always_inline))
fun4(void)
{
    return 1;
}

$ /opt/gcc-12.2.0/bin/gcc -c -Og code.c
In function ‘fun3’,
    inlined from ‘fun2’ at code.c:15:5:
code.c:26:1: error: inlining failed in call to ‘always_inline’ ‘fun4’: function
not considered for inlining
   26 | fun4(void)
      | ^~~~
code.c:9:5: note: called from here
    9 |     p();
      |     ^~~

Reply via email to