From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1FB26385803E; Mon, 1 Aug 2022 23:04:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FB26385803E From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106502] New: Three calls to __attribute__((const)) function Date: Mon, 01 Aug 2022 23:04:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 23:04:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106502 Bug ID: 106502 Summary: Three calls to __attribute__((const)) function Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include int main() { __builtin_puts(std::system_category().name()); } With gcc 12 the resulting assembly is: .file "cat.C" .text .globl main .type main, @function main: .LFB1309: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 pushq %rbx subq $8, %rsp .cfi_offset 3, -24 call _ZNSt3_V215system_categoryEv call _ZNSt3_V215system_categoryEv movq (%rax), %rax addq $16, %rax movq (%rax), %rbx call _ZNSt3_V215system_categoryEv movq %rax, %rdi call *%rbx movq %rax, %rdi call puts movl $0, %eax movq -8(%rbp), %rbx leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1309: .size main, .-main .ident "GCC: (GNU) 12.1.1 20220507 (Red Hat 12.1.1-1)" .section .note.GNU-stack,"",@progbits Why is the std::system_category() function called three times?=