https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114215
--- Comment #4 from cqwrteur <unlvsur at live dot com> --- void test_demovector(checkedvector& vec, __SIZE_TYPE__ x) noexcept { for(__SIZE_TYPE__ i = 0; i < x; i++) vec[i]=5; } void test_demovector_forceinline(checkedvector& vec, __SIZE_TYPE__ x) noexcept { for(__SIZE_TYPE__ i = 0; i < x; i++) vec.index_forceinline(i)=5; } still more instructions for the first one even with a loop. test_demovector(checkedvector&, unsigned long): pushq %r12 movq %rdi, %r12 pushq %rbp movq %rsi, %rbp pushq %rbx xorl %ebx, %ebx .L10: cmpq %rbp, %rbx je .L13 movq %rbx, %rsi movq %r12, %rdi incq %rbx call checkedvector::operator[](unsigned long) movq $5, (%rax) jmp .L10 .L13: popq %rbx popq %rbp popq %r12 ret test_demovector_forceinline(checkedvector&, unsigned long): xorl %eax, %eax .L15: cmpq %rsi, %rax je .L18 movq (%rdi), %rcx movq 8(%rdi), %rdx subq %rcx, %rdx sarq $3, %rdx cmpq %rdx, %rax jb .L16 ud2 .L16: movq $5, (%rcx,%rax,8) incq %rax jmp .L15 .L18: ret