public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110845] New: Function call when it should inline?
@ 2023-07-28 14:27 deco33000 at yandex dot com
  2023-07-28 15:19 ` [Bug c++/110845] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: deco33000 at yandex dot com @ 2023-07-28 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110845
           Summary: Function call when it should inline?
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: deco33000 at yandex dot com
  Target Milestone: ---

Hi,

The below code is inlined in clang (trunk) but not in gcc (13.2).

The code:

#include <format>
#include <iostream>

using namespace std;

constexpr auto f(bool a) -> void {

    if (a) {

        cout << format("hello 1\n");

    } else {

        cout << format("hello 2\n");
    }

}

template <bool T> 
constexpr auto g() -> void {

    if constexpr (T) {

        cout << format("hello 3\n");

    } else {

        cout << format("hello 4\n");
    }
}


int main() {
    f(true);
    f(false);
    g<true>();
    g<false>();

}

flags = -std=c++23 -O3

You can see/test the Godbolt here:
https://godbolt.org/z/aK86nKzYs

Maybe it is related to "format" because without it, it inlines properly.

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

end of thread, other threads:[~2023-07-29 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 14:27 [Bug c++/110845] New: Function call when it should inline? deco33000 at yandex dot com
2023-07-28 15:19 ` [Bug c++/110845] " pinskia at gcc dot gnu.org
2023-07-28 15:34 ` deco33000 at yandex dot com
2023-07-29  7:32 ` xry111 at gcc dot gnu.org
2023-07-29 13:03 ` deco33000 at yandex dot com

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).