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

--- Comment #1 from Jan Schultke <janschultke at googlemail dot com> ---
The std::from_range constructor is even worse
(https://compiler-explorer.com/z/EexY77zKc):

std::inplace_vector<char, 4> f() {
  constexpr std::array elements{'a', 'b', 'c'};
  return { std::from_range, elements };
}

This compiles to:

"f()":
        sub     rsp, 24
        mov     eax, 25185
        mov     WORD PTR [rsp+3], ax
        lea     rax, [rsp+6]
        mov     BYTE PTR [rsp+5], 99
        mov     DWORD PTR [rsp+6], 0
        mov     BYTE PTR [rsp+10], 0
        movzx   eax, BYTE PTR [rsp+10]
        lea     rdx, [rax-2]
        cmp     rdx, 2
        jbe     .L3
        movzx   edx, WORD PTR [rsp+3]
        mov     WORD PTR [rsp+6+rax], dx
        movzx   edx, BYTE PTR [rsp+5]
        mov     BYTE PTR [rsp+8+rax], dl
        mov     eax, DWORD PTR [rsp+6]
        add     BYTE PTR [rsp+10], 3
        movzx   edx, BYTE PTR [rsp+10]
        add     rsp, 24
        sal     rdx, 32
        or      rax, rdx
        ret

Reply via email to