[Bug c++/97681] New: noinline attribute ignored on constexpr function

ldalessandro at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Nov 2 21:11:46 GMT 2020


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

            Bug ID: 97681
           Summary: noinline attribute ignored on constexpr function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

GCC inlines function marked noinline when the function is marked as
`constexpr`, even if it is not used in `constexpr` context.
https://godbolt.org/z/b94Kje

```
[[gnu::noinline]] constexpr auto a() { return 1; }
[[gnu::noinline]] auto b() { return 2; }

int main() {
    int i = a();
    int j = b();
    return i + j;
}
```

```
b():
        mov     eax, 2
        ret
main:
        call    b()
        add     eax, 1
        ret
```


More information about the Gcc-bugs mailing list