函数返回值接收过程的原理
代码
#include<iostream>
using namespace std;
#include<vector>
vector<int> getv() {
vector<int>v;
return v;
}
void test01()
{
vector<int>v = getv();
}
int main()
{
test01();
return 0;
}
如题,我用一个返回容器的函数定义了一个空的容器vector,没有赋值和构造,用一个对应的vector容器去接收这个返回值。那么,是不是可以理解vector成容器在接收getv()函数的过程中,将返回值变成指针的形式,然后再解引用返回给了对应的数据. 原理?这就是原理
sh-5.1$ cat main.cpp
#include <iostream>
#include <vector>
using namespace std;
vector<int> getv() {
vector<int> v;
return v;
}
void test01() {vector<int> v = getv();}
int main() {
test01();
return 0;
}
sh-5.1$ g++ -S main.cpp
sh-5.1$ cat main.s
.file "main.cpp"
.text
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.section .text._ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD5Ev,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
.type _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev, @function
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev:
.LFB2128:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSaIiED2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2128:
.size _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev, .-_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
.weak _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev
.set _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
.section .text._ZNSt12_Vector_baseIiSaIiEEC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEEC5Ev,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEEC2Ev
.type _ZNSt12_Vector_baseIiSaIiEEC2Ev, @function
_ZNSt12_Vector_baseIiSaIiEEC2Ev:
.LFB2130:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2130:
.size _ZNSt12_Vector_baseIiSaIiEEC2Ev, .-_ZNSt12_Vector_baseIiSaIiEEC2Ev
.weak _ZNSt12_Vector_baseIiSaIiEEC1Ev
.set _ZNSt12_Vector_baseIiSaIiEEC1Ev,_ZNSt12_Vector_baseIiSaIiEEC2Ev
.section .text._ZNSt6vectorIiSaIiEEC2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEEC5Ev,comdat
.align 2
.weak _ZNSt6vectorIiSaIiEEC2Ev
.type _ZNSt6vectorIiSaIiEEC2Ev, @function
_ZNSt6vectorIiSaIiEEC2Ev:
.LFB2132:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEEC2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2132:
.size _ZNSt6vectorIiSaIiEEC2Ev, .-_ZNSt6vectorIiSaIiEEC2Ev
.weak _ZNSt6vectorIiSaIiEEC1Ev
.set _ZNSt6vectorIiSaIiEEC1Ev,_ZNSt6vectorIiSaIiEEC2Ev
.text
.globl _Z4getvv
.type _Z4getvv, @function
_Z4getvv:
.LFB2123:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt6vectorIiSaIiEEC1Ev
nop
movq -8(%rbp), %rax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2123:
.size _Z4getvv, .-_Z4getvv
.globl _Z6test01v
.type _Z6test01v, @function
_Z6test01v:
.LFB2140:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %fs:40, %rax
movq %rax, -8(%rbp)
xorl %eax, %eax
leaq -32(%rbp), %rax
movq %rax, %rdi
call _Z4getvv
leaq -32(%rbp), %rax
movq %rax, %rdi
call _ZNSt6vectorIiSaIiEED1Ev
movq -8(%rbp), %rax
subq %fs:40, %rax
je .L7
call __stack_chk_fail@PLT
.L7:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2140:
.size _Z6test01v, .-_Z6test01v
.globl main
.type main, @function
main:
.LFB2141:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
call _Z6test01v
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2141:
.size main, .-main
.section .text._ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC5Ev,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
.type _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev, @function
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev:
.LFB2406:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSaIiEC2Ev
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2406:
.size _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev, .-_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
.weak _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
.set _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
.section .text._ZNSaIiED2Ev,"axG",@progbits,_ZNSaIiED5Ev,comdat
.align 2
.weak _ZNSaIiED2Ev
.type _ZNSaIiED2Ev, @function
_ZNSaIiED2Ev:
.LFB2409:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt15__new_allocatorIiED2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2409:
.size _ZNSaIiED2Ev, .-_ZNSaIiED2Ev
.weak _ZNSaIiED1Ev
.set _ZNSaIiED1Ev,_ZNSaIiED2Ev
.section .text._ZNSt12_Vector_baseIiSaIiEED2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEED2Ev
.type _ZNSt12_Vector_baseIiSaIiEED2Ev, @function
_ZNSt12_Vector_baseIiSaIiEED2Ev:
.LFB2412:
.cfi_startproc
.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
.cfi_lsda 0x1b,.LLSDA2412
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq 16(%rax), %rdx
movq -8(%rbp), %rax
movq (%rax), %rax
subq %rax, %rdx
movq %rdx, %rax
sarq $2, %rax
movq %rax, %rdx
movq -8(%rbp), %rax
movq (%rax), %rcx
movq -8(%rbp), %rax
movq %rcx, %rsi
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2412:
.globl __gxx_personality_v0
.section .gcc_except_table._ZNSt12_Vector_baseIiSaIiEED2Ev,"aG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
.LLSDA2412:
.byte 0xff
.byte 0xff
.byte 0x1
.uleb128 .LLSDACSE2412-.LLSDACSB2412
.LLSDACSB2412:
.LLSDACSE2412:
.section .text._ZNSt12_Vector_baseIiSaIiEED2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
.size _ZNSt12_Vector_baseIiSaIiEED2Ev, .-_ZNSt12_Vector_baseIiSaIiEED2Ev
.weak _ZNSt12_Vector_baseIiSaIiEED1Ev
.set _ZNSt12_Vector_baseIiSaIiEED1Ev,_ZNSt12_Vector_baseIiSaIiEED2Ev
.section .text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
.align 2
.weak _ZNSt6vectorIiSaIiEED2Ev
.type _ZNSt6vectorIiSaIiEED2Ev, @function
_ZNSt6vectorIiSaIiEED2Ev:
.LFB2415:
.cfi_startproc
.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
.cfi_lsda 0x1b,.LLSDA2415
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
movq %rax, %rdx
movq -8(%rbp), %rax
movq 8(%rax), %rcx
movq -8(%rbp), %rax
movq (%rax), %rax
movq %rcx, %rsi
movq %rax, %rdi
call _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt12_Vector_baseIiSaIiEED2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2415:
.section .gcc_except_table._ZNSt6vectorIiSaIiEED2Ev,"aG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
.LLSDA2415:
.byte 0xff
.byte 0xff
.byte 0x1
.uleb128 .LLSDACSE2415-.LLSDACSB2415
.LLSDACSB2415:
.LLSDACSE2415:
.section .text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
.size _ZNSt6vectorIiSaIiEED2Ev, .-_ZNSt6vectorIiSaIiEED2Ev
.weak _ZNSt6vectorIiSaIiEED1Ev
.set _ZNSt6vectorIiSaIiEED1Ev,_ZNSt6vectorIiSaIiEED2Ev
.section .text._ZNSaIiEC2Ev,"axG",@progbits,_ZNSaIiEC5Ev,comdat
.align 2
.weak _ZNSaIiEC2Ev
.type _ZNSaIiEC2Ev, @function
_ZNSaIiEC2Ev:
.LFB2525:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZNSt15__new_allocatorIiEC2Ev
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2525:
.size _ZNSaIiEC2Ev, .-_ZNSaIiEC2Ev
.weak _ZNSaIiEC1Ev
.set _ZNSaIiEC1Ev,_ZNSaIiEC2Ev
.section .text._ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC5Ev,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
.type _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev, @function
_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev:
.LFB2528:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq $0, (%rax)
movq -8(%rbp), %rax
movq $0, 8(%rax)
movq -8(%rbp), %rax
movq $0, 16(%rax)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2528:
.size _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev, .-_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
.weak _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC1Ev
.set _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC1Ev,_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
.section .text._ZNSt15__new_allocatorIiED2Ev,"axG",@progbits,_ZNSt15__new_allocatorIiED5Ev,comdat
.align 2
.weak _ZNSt15__new_allocatorIiED2Ev
.type _ZNSt15__new_allocatorIiED2Ev, @function
_ZNSt15__new_allocatorIiED2Ev:
.LFB2531:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2531:
.size _ZNSt15__new_allocatorIiED2Ev, .-_ZNSt15__new_allocatorIiED2Ev
.weak _ZNSt15__new_allocatorIiED1Ev
.set _ZNSt15__new_allocatorIiED1Ev,_ZNSt15__new_allocatorIiED2Ev
.section .text._ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
.type _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim, @function
_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim:
.LFB2533:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq %rdx, -24(%rbp)
cmpq $0, -16(%rbp)
je .L19
movq -8(%rbp), %rax
movq -24(%rbp), %rdx
movq -16(%rbp), %rcx
movq %rcx, %rsi
movq %rax, %rdi
call _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
.L19:
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2533:
.size _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim, .-_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
.section .text._ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv,comdat
.align 2
.weak _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
.type _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv, @function
_ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv:
.LFB2534:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2534:
.size _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv, .-_ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
.section .text._ZSt8_DestroyIPiiEvT_S1_RSaIT0_E,"axG",@progbits,_ZSt8_DestroyIPiiEvT_S1_RSaIT0_E,comdat
.weak _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
.type _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E, @function
_ZSt8_DestroyIPiiEvT_S1_RSaIT0_E:
.LFB2535:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq %rdx, -24(%rbp)
movq -16(%rbp), %rdx
movq -8(%rbp), %rax
movq %rdx, %rsi
movq %rax, %rdi
call _ZSt8_DestroyIPiEvT_S1_
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2535:
.size _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E, .-_ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
.section .text._ZNSt15__new_allocatorIiEC2Ev,"axG",@progbits,_ZNSt15__new_allocatorIiEC5Ev,comdat
.align 2
.weak _ZNSt15__new_allocatorIiEC2Ev
.type _ZNSt15__new_allocatorIiEC2Ev, @function
_ZNSt15__new_allocatorIiEC2Ev:
.LFB2612:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2612:
.size _ZNSt15__new_allocatorIiEC2Ev, .-_ZNSt15__new_allocatorIiEC2Ev
.weak _ZNSt15__new_allocatorIiEC1Ev
.set _ZNSt15__new_allocatorIiEC1Ev,_ZNSt15__new_allocatorIiEC2Ev
.section .text._ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim,"axG",@progbits,_ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim,comdat
.weak _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
.type _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim, @function
_ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim:
.LFB2614:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq %rdx, -24(%rbp)
movq -24(%rbp), %rdx
movq -16(%rbp), %rcx
movq -8(%rbp), %rax
movq %rcx, %rsi
movq %rax, %rdi
call _ZNSt15__new_allocatorIiE10deallocateEPim
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2614:
.size _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim, .-_ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
.section .text._ZSt8_DestroyIPiEvT_S1_,"axG",@progbits,_ZSt8_DestroyIPiEvT_S1_,comdat
.weak _ZSt8_DestroyIPiEvT_S1_
.type _ZSt8_DestroyIPiEvT_S1_, @function
_ZSt8_DestroyIPiEvT_S1_:
.LFB2615:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq -16(%rbp), %rdx
movq -8(%rbp), %rax
movq %rdx, %rsi
movq %rax, %rdi
call _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2615:
.size _ZSt8_DestroyIPiEvT_S1_, .-_ZSt8_DestroyIPiEvT_S1_
.section .text._ZNSt15__new_allocatorIiE10deallocateEPim,"axG",@progbits,_ZNSt15__new_allocatorIiE10deallocateEPim,comdat
.align 2
.weak _ZNSt15__new_allocatorIiE10deallocateEPim
.type _ZNSt15__new_allocatorIiE10deallocateEPim, @function
_ZNSt15__new_allocatorIiE10deallocateEPim:
.LFB2674:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq %rdx, -24(%rbp)
movq -24(%rbp), %rax
leaq 0(,%rax,4), %rdx
movq -16(%rbp), %rax
movq %rdx, %rsi
movq %rax, %rdi
call _ZdlPvm@PLT
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2674:
.size _ZNSt15__new_allocatorIiE10deallocateEPim, .-_ZNSt15__new_allocatorIiE10deallocateEPim
.section .text._ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_,"axG",@progbits,_ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_,comdat
.weak _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
.type _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_, @function
_ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_:
.LFB2675:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2675:
.size _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_, .-_ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
.text
.type _Z41__static_initialization_and_destruction_0ii, @function
_Z41__static_initialization_and_destruction_0ii:
.LFB2710:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
cmpl $1, -4(%rbp)
jne .L31
cmpl $65535, -8(%rbp)
jne .L31
leaq _ZStL8__ioinit(%rip), %rax
movq %rax, %rdi
call _ZNSt8ios_base4InitC1Ev@PLT
leaq __dso_handle(%rip), %rax
movq %rax, %rdx
leaq _ZStL8__ioinit(%rip), %rax
movq %rax, %rsi
movq _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rax
movq %rax, %rdi
call __cxa_atexit@PLT
.L31:
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2710:
.size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
.type _GLOBAL__sub_I__Z4getvv, @function
_GLOBAL__sub_I__Z4getvv:
.LFB2711:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $65535, %esi
movl $1, %edi
call _Z41__static_initialization_and_destruction_0ii
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE2711:
.size _GLOBAL__sub_I__Z4getvv, .-_GLOBAL__sub_I__Z4getvv
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I__Z4getvv
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
.section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
.align 8
.type DW.ref.__gxx_personality_v0, @object
.size DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
.quad __gxx_personality_v0
.hidden __dso_handle
.ident "GCC: (GNU) 12.2.1 20230111"
.section .note.GNU-stack,"",@progbits
sh-5.1$
有点奇怪。
这个应该只适用于stl的东西吧
<可以理解vector成容器在接收getv()函数的过程中,将返回值变成指针的形式,然后再解引用返回给了对应的数据.>
这个应该是对的,但不是所有类型都这样。 我觉得在学习阶段可以适当探索底层,但是不能一刨到底,一下就把工程搞大了
我对返回的理解是,编译器把返回的结果打了个包,然后交给了接收它的变量,交接的时候当面清点,交接完这个包就丢掉了, 不要试图再去找这个包,就算找到了皮,里边的东西也不是你想要的了
还有,“定义了一个空的容器vector,没有赋值和构造”, 这句有问题,定义完成构造就必定完成 谢谢老大分享。。。。
页:
[1]