Different output between 9.2 and 8.3: Regression or expected?
Hong X
hongx@ibm.com
Tue Sep 17 21:51:00 GMT 2019
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
More information about the Gcc-help
mailing list