Different output between 9.2 and 8.3: Regression or expected?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
 
I compiled the following code on godbolt.org using x86-64 gcc 9.2 and 8.3:
 
#include <vector>
int f () {
    auto a = std::vector<int>();
}
 
gcc 9.2 outputs (for f):
 
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $32, %rsp
        movq    $0, -32(%rbp)
        movq    $0, -24(%rbp)
        movq    $0, -16(%rbp)
        leaq    -32(%rbp), %rax
        movq    %rax, %rdi
        call    std::vector<int, std::allocator<int> >::vector() [complete object constructor]
        leaq    -32(%rbp), %rax
        movq    %rax, %rdi
        call    std::vector<int, std::allocator<int> >::~vector() [complete object destructor]
        nop
        leave
        ret
 
gcc 8.3 outputs (for f):
 
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $32, %rsp
        leaq    -32(%rbp), %rax
        movq    %rax, %rdi
        call    std::vector<int, std::allocator<int> >::vector() [complete object constructor]
        leaq    -32(%rbp), %rax
        movq    %rax, %rdi
        call    std::vector<int, std::allocator<int> >::~vector() [complete object destructor]
        nop
        leave
        ret
 
Note that on gcc 9.2, I see the following additional asm code generated for v1, which gcc 8.3 does not:
 
movq $0, -32(%rbp)
movq $0, -24(%rbp)
movq $0, -16(%rbp)
 
I played with the different versions on godbolt, which can be seen here: https://godbolt.org/z/6u8rgK (I don't have gcc 9.2 installed locally and therefore it is hard for me to reproduce locally).
 
I'm wondering is this expected behavior?
 
Thanks,
Hong





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux