C++ Logo

std-proposals

Advanced search

Re: [std-proposals] is_trivially_copyable_in_reality

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Thu, 29 Jan 2026 14:00:04 +0100
Il 29/01/26 13:30, Frederick Virchanza Gotham via Std-Proposals ha scritto:
>
> GodBolt:https://godbolt.org/z/xqr6813q7
>
> Let's look at how the assembler comes out. Here's CopyA:
>
> shl $0x15,%rdx
> jmp memcpy
>
> First instructions shifts the count left 21 places (to convert to bytes).
> Second instruction jumps to memcpy.
> No surprises here.
>
> Now let's look at CopyB:
>
> test %rdx,%rdx
> je 60 <CopyB(void*, S const*, unsigned long)+0x50>
> push %r13
> shl $0x15,%rdx
> mov %rsi,%r13
> push %r12
> mov %rdi,%r12
> push %rbp
> mov %rdx,%rbp
> push %rbx
> xor %ebx,%ebx
> sub $0x8,%rsp
> xchg %ax,%ax
> lea (%r12,%rbx,1),%rdi
> lea 0x0(%r13,%rbx,1),%rsi
> mov $0x200000,%edx
> add $0x200000,%rbx
> call 4a <CopyB(void*, S const*, unsigned long)+0x3a>
> R_X86_64_PLT32 memcpy-0x4
> cmp %rbx,%rbp
> jne 30 <CopyB(void*, S const*, unsigned long)+0x20>
> add $0x8,%rsp
> pop %rbx
> pop %rbp
> pop %r12
> pop %r13
> ret
>
> The above is more complicated, and we see that memcpy is called
> several times in a loop.


I've stopped reading right here: look up `restrict`.

Can we please *stop* with email threads that *do not contain a concrete
proposal*?

--
Giuseppe D'Angelo

Received on 2026-01-29 13:00:11