public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110793] New: regression in optimizing unused string
@ 2023-07-24 14:17 barry.revzin at gmail dot com
  2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: barry.revzin at gmail dot com @ 2023-07-24 14:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110793
           Summary: regression in optimizing unused string
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider this reduced, silly-looking example:

#include <string>

inline int zero(std::string const& = {}) { return 0; }

int main() {
    return zero();
}

In several versions of gcc (12.2, 11.4, 10.5), this simply compiles to:

main:
        xor     eax, eax
        ret

But in 13.1 (C++17, but not C++20), we get:

main:
        sub     rsp, 40
        lea     rax, [rsp+16]
        mov     rdi, rsp
        mov     BYTE PTR [rsp+16], 0
        mov     QWORD PTR [rsp], rax
        mov     QWORD PTR [rsp+8], 0
        call    std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_dispose()
        xor     eax, eax
        add     rsp, 40
        ret

Notably, 13.1 C++20 and C++23 also compiles to just xor. 

I'm not sure if this is a language or library issue, so tagging it language for
now.

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

end of thread, other threads:[~2023-07-24 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 14:17 [Bug c++/110793] New: regression in optimizing unused string barry.revzin at gmail dot com
2023-07-24 14:36 ` [Bug c++/110793] " redi at gcc dot gnu.org
2023-07-24 14:48 ` [Bug ipa/110793] " pinskia at gcc dot gnu.org
2023-07-24 15:04 ` pinskia at gcc dot gnu.org
2023-07-24 15:04 ` pinskia at gcc dot gnu.org

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