鱼C论坛

 找回密码
 立即注册
查看: 1635|回复: 4

函数返回值接收过程的原理

[复制链接]
发表于 2023-2-17 22:04:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x

代码
#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()函数的过程中,将返回值变成指针的形式,然后再解引用返回给了对应的数据.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-2-17 22:26:08 | 显示全部楼层
原理?这就是原理

  1. sh-5.1$ cat main.cpp
  2. #include <iostream>
  3. #include <vector>

  4. using namespace std;

  5. vector<int> getv() {
  6.     vector<int> v;
  7.     return v;
  8. }

  9. void test01() {vector<int> v = getv();}

  10. int main() {
  11.     test01();
  12.     return 0;
  13. }
  14. sh-5.1$ g++ -S main.cpp
  15. sh-5.1$ cat main.s
  16.         .file        "main.cpp"
  17.         .text
  18.         .local        _ZStL8__ioinit
  19.         .comm        _ZStL8__ioinit,1,1
  20.         .section        .text._ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD5Ev,comdat
  21.         .align 2
  22.         .weak        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
  23.         .type        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev, @function
  24. _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev:
  25. .LFB2128:
  26.         .cfi_startproc
  27.         pushq        %rbp
  28.         .cfi_def_cfa_offset 16
  29.         .cfi_offset 6, -16
  30.         movq        %rsp, %rbp
  31.         .cfi_def_cfa_register 6
  32.         subq        $16, %rsp
  33.         movq        %rdi, -8(%rbp)
  34.         movq        -8(%rbp), %rax
  35.         movq        %rax, %rdi
  36.         call        _ZNSaIiED2Ev
  37.         nop
  38.         leave
  39.         .cfi_def_cfa 7, 8
  40.         ret
  41.         .cfi_endproc
  42. .LFE2128:
  43.         .size        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev, .-_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
  44.         .weak        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev
  45.         .set        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
  46.         .section        .text._ZNSt12_Vector_baseIiSaIiEEC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEEC5Ev,comdat
  47.         .align 2
  48.         .weak        _ZNSt12_Vector_baseIiSaIiEEC2Ev
  49.         .type        _ZNSt12_Vector_baseIiSaIiEEC2Ev, @function
  50. _ZNSt12_Vector_baseIiSaIiEEC2Ev:
  51. .LFB2130:
  52.         .cfi_startproc
  53.         pushq        %rbp
  54.         .cfi_def_cfa_offset 16
  55.         .cfi_offset 6, -16
  56.         movq        %rsp, %rbp
  57.         .cfi_def_cfa_register 6
  58.         subq        $16, %rsp
  59.         movq        %rdi, -8(%rbp)
  60.         movq        -8(%rbp), %rax
  61.         movq        %rax, %rdi
  62.         call        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
  63.         nop
  64.         leave
  65.         .cfi_def_cfa 7, 8
  66.         ret
  67.         .cfi_endproc
  68. .LFE2130:
  69.         .size        _ZNSt12_Vector_baseIiSaIiEEC2Ev, .-_ZNSt12_Vector_baseIiSaIiEEC2Ev
  70.         .weak        _ZNSt12_Vector_baseIiSaIiEEC1Ev
  71.         .set        _ZNSt12_Vector_baseIiSaIiEEC1Ev,_ZNSt12_Vector_baseIiSaIiEEC2Ev
  72.         .section        .text._ZNSt6vectorIiSaIiEEC2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEEC5Ev,comdat
  73.         .align 2
  74.         .weak        _ZNSt6vectorIiSaIiEEC2Ev
  75.         .type        _ZNSt6vectorIiSaIiEEC2Ev, @function
  76. _ZNSt6vectorIiSaIiEEC2Ev:
  77. .LFB2132:
  78.         .cfi_startproc
  79.         pushq        %rbp
  80.         .cfi_def_cfa_offset 16
  81.         .cfi_offset 6, -16
  82.         movq        %rsp, %rbp
  83.         .cfi_def_cfa_register 6
  84.         subq        $16, %rsp
  85.         movq        %rdi, -8(%rbp)
  86.         movq        -8(%rbp), %rax
  87.         movq        %rax, %rdi
  88.         call        _ZNSt12_Vector_baseIiSaIiEEC2Ev
  89.         nop
  90.         leave
  91.         .cfi_def_cfa 7, 8
  92.         ret
  93.         .cfi_endproc
  94. .LFE2132:
  95.         .size        _ZNSt6vectorIiSaIiEEC2Ev, .-_ZNSt6vectorIiSaIiEEC2Ev
  96.         .weak        _ZNSt6vectorIiSaIiEEC1Ev
  97.         .set        _ZNSt6vectorIiSaIiEEC1Ev,_ZNSt6vectorIiSaIiEEC2Ev
  98.         .text
  99.         .globl        _Z4getvv
  100.         .type        _Z4getvv, @function
  101. _Z4getvv:
  102. .LFB2123:
  103.         .cfi_startproc
  104.         pushq        %rbp
  105.         .cfi_def_cfa_offset 16
  106.         .cfi_offset 6, -16
  107.         movq        %rsp, %rbp
  108.         .cfi_def_cfa_register 6
  109.         subq        $16, %rsp
  110.         movq        %rdi, -8(%rbp)
  111.         movq        -8(%rbp), %rax
  112.         movq        %rax, %rdi
  113.         call        _ZNSt6vectorIiSaIiEEC1Ev
  114.         nop
  115.         movq        -8(%rbp), %rax
  116.         leave
  117.         .cfi_def_cfa 7, 8
  118.         ret
  119.         .cfi_endproc
  120. .LFE2123:
  121.         .size        _Z4getvv, .-_Z4getvv
  122.         .globl        _Z6test01v
  123.         .type        _Z6test01v, @function
  124. _Z6test01v:
  125. .LFB2140:
  126.         .cfi_startproc
  127.         pushq        %rbp
  128.         .cfi_def_cfa_offset 16
  129.         .cfi_offset 6, -16
  130.         movq        %rsp, %rbp
  131.         .cfi_def_cfa_register 6
  132.         subq        $32, %rsp
  133.         movq        %fs:40, %rax
  134.         movq        %rax, -8(%rbp)
  135.         xorl        %eax, %eax
  136.         leaq        -32(%rbp), %rax
  137.         movq        %rax, %rdi
  138.         call        _Z4getvv
  139.         leaq        -32(%rbp), %rax
  140.         movq        %rax, %rdi
  141.         call        _ZNSt6vectorIiSaIiEED1Ev
  142.         movq        -8(%rbp), %rax
  143.         subq        %fs:40, %rax
  144.         je        .L7
  145.         call        __stack_chk_fail@PLT
  146. .L7:
  147.         leave
  148.         .cfi_def_cfa 7, 8
  149.         ret
  150.         .cfi_endproc
  151. .LFE2140:
  152.         .size        _Z6test01v, .-_Z6test01v
  153.         .globl        main
  154.         .type        main, @function
  155. main:
  156. .LFB2141:
  157.         .cfi_startproc
  158.         pushq        %rbp
  159.         .cfi_def_cfa_offset 16
  160.         .cfi_offset 6, -16
  161.         movq        %rsp, %rbp
  162.         .cfi_def_cfa_register 6
  163.         call        _Z6test01v
  164.         movl        $0, %eax
  165.         popq        %rbp
  166.         .cfi_def_cfa 7, 8
  167.         ret
  168.         .cfi_endproc
  169. .LFE2141:
  170.         .size        main, .-main
  171.         .section        .text._ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC5Ev,comdat
  172.         .align 2
  173.         .weak        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
  174.         .type        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev, @function
  175. _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev:
  176. .LFB2406:
  177.         .cfi_startproc
  178.         pushq        %rbp
  179.         .cfi_def_cfa_offset 16
  180.         .cfi_offset 6, -16
  181.         movq        %rsp, %rbp
  182.         .cfi_def_cfa_register 6
  183.         subq        $16, %rsp
  184.         movq        %rdi, -8(%rbp)
  185.         movq        -8(%rbp), %rax
  186.         movq        %rax, %rdi
  187.         call        _ZNSaIiEC2Ev
  188.         movq        -8(%rbp), %rax
  189.         movq        %rax, %rdi
  190.         call        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
  191.         nop
  192.         leave
  193.         .cfi_def_cfa 7, 8
  194.         ret
  195.         .cfi_endproc
  196. .LFE2406:
  197.         .size        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev, .-_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
  198.         .weak        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
  199.         .set        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
  200.         .section        .text._ZNSaIiED2Ev,"axG",@progbits,_ZNSaIiED5Ev,comdat
  201.         .align 2
  202.         .weak        _ZNSaIiED2Ev
  203.         .type        _ZNSaIiED2Ev, @function
  204. _ZNSaIiED2Ev:
  205. .LFB2409:
  206.         .cfi_startproc
  207.         pushq        %rbp
  208.         .cfi_def_cfa_offset 16
  209.         .cfi_offset 6, -16
  210.         movq        %rsp, %rbp
  211.         .cfi_def_cfa_register 6
  212.         subq        $16, %rsp
  213.         movq        %rdi, -8(%rbp)
  214.         movq        -8(%rbp), %rax
  215.         movq        %rax, %rdi
  216.         call        _ZNSt15__new_allocatorIiED2Ev
  217.         nop
  218.         leave
  219.         .cfi_def_cfa 7, 8
  220.         ret
  221.         .cfi_endproc
  222. .LFE2409:
  223.         .size        _ZNSaIiED2Ev, .-_ZNSaIiED2Ev
  224.         .weak        _ZNSaIiED1Ev
  225.         .set        _ZNSaIiED1Ev,_ZNSaIiED2Ev
  226.         .section        .text._ZNSt12_Vector_baseIiSaIiEED2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
  227.         .align 2
  228.         .weak        _ZNSt12_Vector_baseIiSaIiEED2Ev
  229.         .type        _ZNSt12_Vector_baseIiSaIiEED2Ev, @function
  230. _ZNSt12_Vector_baseIiSaIiEED2Ev:
  231. .LFB2412:
  232.         .cfi_startproc
  233.         .cfi_personality 0x9b,DW.ref.__gxx_personality_v0
  234.         .cfi_lsda 0x1b,.LLSDA2412
  235.         pushq        %rbp
  236.         .cfi_def_cfa_offset 16
  237.         .cfi_offset 6, -16
  238.         movq        %rsp, %rbp
  239.         .cfi_def_cfa_register 6
  240.         subq        $16, %rsp
  241.         movq        %rdi, -8(%rbp)
  242.         movq        -8(%rbp), %rax
  243.         movq        16(%rax), %rdx
  244.         movq        -8(%rbp), %rax
  245.         movq        (%rax), %rax
  246.         subq        %rax, %rdx
  247.         movq        %rdx, %rax
  248.         sarq        $2, %rax
  249.         movq        %rax, %rdx
  250.         movq        -8(%rbp), %rax
  251.         movq        (%rax), %rcx
  252.         movq        -8(%rbp), %rax
  253.         movq        %rcx, %rsi
  254.         movq        %rax, %rdi
  255.         call        _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
  256.         movq        -8(%rbp), %rax
  257.         movq        %rax, %rdi
  258.         call        _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev
  259.         nop
  260.         leave
  261.         .cfi_def_cfa 7, 8
  262.         ret
  263.         .cfi_endproc
  264. .LFE2412:
  265.         .globl        __gxx_personality_v0
  266.         .section        .gcc_except_table._ZNSt12_Vector_baseIiSaIiEED2Ev,"aG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
  267. .LLSDA2412:
  268.         .byte        0xff
  269.         .byte        0xff
  270.         .byte        0x1
  271.         .uleb128 .LLSDACSE2412-.LLSDACSB2412
  272. .LLSDACSB2412:
  273. .LLSDACSE2412:
  274.         .section        .text._ZNSt12_Vector_baseIiSaIiEED2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEED5Ev,comdat
  275.         .size        _ZNSt12_Vector_baseIiSaIiEED2Ev, .-_ZNSt12_Vector_baseIiSaIiEED2Ev
  276.         .weak        _ZNSt12_Vector_baseIiSaIiEED1Ev
  277.         .set        _ZNSt12_Vector_baseIiSaIiEED1Ev,_ZNSt12_Vector_baseIiSaIiEED2Ev
  278.         .section        .text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
  279.         .align 2
  280.         .weak        _ZNSt6vectorIiSaIiEED2Ev
  281.         .type        _ZNSt6vectorIiSaIiEED2Ev, @function
  282. _ZNSt6vectorIiSaIiEED2Ev:
  283. .LFB2415:
  284.         .cfi_startproc
  285.         .cfi_personality 0x9b,DW.ref.__gxx_personality_v0
  286.         .cfi_lsda 0x1b,.LLSDA2415
  287.         pushq        %rbp
  288.         .cfi_def_cfa_offset 16
  289.         .cfi_offset 6, -16
  290.         movq        %rsp, %rbp
  291.         .cfi_def_cfa_register 6
  292.         subq        $16, %rsp
  293.         movq        %rdi, -8(%rbp)
  294.         movq        -8(%rbp), %rax
  295.         movq        %rax, %rdi
  296.         call        _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
  297.         movq        %rax, %rdx
  298.         movq        -8(%rbp), %rax
  299.         movq        8(%rax), %rcx
  300.         movq        -8(%rbp), %rax
  301.         movq        (%rax), %rax
  302.         movq        %rcx, %rsi
  303.         movq        %rax, %rdi
  304.         call        _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
  305.         movq        -8(%rbp), %rax
  306.         movq        %rax, %rdi
  307.         call        _ZNSt12_Vector_baseIiSaIiEED2Ev
  308.         nop
  309.         leave
  310.         .cfi_def_cfa 7, 8
  311.         ret
  312.         .cfi_endproc
  313. .LFE2415:
  314.         .section        .gcc_except_table._ZNSt6vectorIiSaIiEED2Ev,"aG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
  315. .LLSDA2415:
  316.         .byte        0xff
  317.         .byte        0xff
  318.         .byte        0x1
  319.         .uleb128 .LLSDACSE2415-.LLSDACSB2415
  320. .LLSDACSB2415:
  321. .LLSDACSE2415:
  322.         .section        .text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
  323.         .size        _ZNSt6vectorIiSaIiEED2Ev, .-_ZNSt6vectorIiSaIiEED2Ev
  324.         .weak        _ZNSt6vectorIiSaIiEED1Ev
  325.         .set        _ZNSt6vectorIiSaIiEED1Ev,_ZNSt6vectorIiSaIiEED2Ev
  326.         .section        .text._ZNSaIiEC2Ev,"axG",@progbits,_ZNSaIiEC5Ev,comdat
  327.         .align 2
  328.         .weak        _ZNSaIiEC2Ev
  329.         .type        _ZNSaIiEC2Ev, @function
  330. _ZNSaIiEC2Ev:
  331. .LFB2525:
  332.         .cfi_startproc
  333.         pushq        %rbp
  334.         .cfi_def_cfa_offset 16
  335.         .cfi_offset 6, -16
  336.         movq        %rsp, %rbp
  337.         .cfi_def_cfa_register 6
  338.         subq        $16, %rsp
  339.         movq        %rdi, -8(%rbp)
  340.         movq        -8(%rbp), %rax
  341.         movq        %rax, %rdi
  342.         call        _ZNSt15__new_allocatorIiEC2Ev
  343.         nop
  344.         leave
  345.         .cfi_def_cfa 7, 8
  346.         ret
  347.         .cfi_endproc
  348. .LFE2525:
  349.         .size        _ZNSaIiEC2Ev, .-_ZNSaIiEC2Ev
  350.         .weak        _ZNSaIiEC1Ev
  351.         .set        _ZNSaIiEC1Ev,_ZNSaIiEC2Ev
  352.         .section        .text._ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC5Ev,comdat
  353.         .align 2
  354.         .weak        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
  355.         .type        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev, @function
  356. _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev:
  357. .LFB2528:
  358.         .cfi_startproc
  359.         pushq        %rbp
  360.         .cfi_def_cfa_offset 16
  361.         .cfi_offset 6, -16
  362.         movq        %rsp, %rbp
  363.         .cfi_def_cfa_register 6
  364.         movq        %rdi, -8(%rbp)
  365.         movq        -8(%rbp), %rax
  366.         movq        $0, (%rax)
  367.         movq        -8(%rbp), %rax
  368.         movq        $0, 8(%rax)
  369.         movq        -8(%rbp), %rax
  370.         movq        $0, 16(%rax)
  371.         nop
  372.         popq        %rbp
  373.         .cfi_def_cfa 7, 8
  374.         ret
  375.         .cfi_endproc
  376. .LFE2528:
  377.         .size        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev, .-_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
  378.         .weak        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC1Ev
  379.         .set        _ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC1Ev,_ZNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataC2Ev
  380.         .section        .text._ZNSt15__new_allocatorIiED2Ev,"axG",@progbits,_ZNSt15__new_allocatorIiED5Ev,comdat
  381.         .align 2
  382.         .weak        _ZNSt15__new_allocatorIiED2Ev
  383.         .type        _ZNSt15__new_allocatorIiED2Ev, @function
  384. _ZNSt15__new_allocatorIiED2Ev:
  385. .LFB2531:
  386.         .cfi_startproc
  387.         pushq        %rbp
  388.         .cfi_def_cfa_offset 16
  389.         .cfi_offset 6, -16
  390.         movq        %rsp, %rbp
  391.         .cfi_def_cfa_register 6
  392.         movq        %rdi, -8(%rbp)
  393.         nop
  394.         popq        %rbp
  395.         .cfi_def_cfa 7, 8
  396.         ret
  397.         .cfi_endproc
  398. .LFE2531:
  399.         .size        _ZNSt15__new_allocatorIiED2Ev, .-_ZNSt15__new_allocatorIiED2Ev
  400.         .weak        _ZNSt15__new_allocatorIiED1Ev
  401.         .set        _ZNSt15__new_allocatorIiED1Ev,_ZNSt15__new_allocatorIiED2Ev
  402.         .section        .text._ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim,comdat
  403.         .align 2
  404.         .weak        _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
  405.         .type        _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim, @function
  406. _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim:
  407. .LFB2533:
  408.         .cfi_startproc
  409.         pushq        %rbp
  410.         .cfi_def_cfa_offset 16
  411.         .cfi_offset 6, -16
  412.         movq        %rsp, %rbp
  413.         .cfi_def_cfa_register 6
  414.         subq        $32, %rsp
  415.         movq        %rdi, -8(%rbp)
  416.         movq        %rsi, -16(%rbp)
  417.         movq        %rdx, -24(%rbp)
  418.         cmpq        $0, -16(%rbp)
  419.         je        .L19
  420.         movq        -8(%rbp), %rax
  421.         movq        -24(%rbp), %rdx
  422.         movq        -16(%rbp), %rcx
  423.         movq        %rcx, %rsi
  424.         movq        %rax, %rdi
  425.         call        _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
  426. .L19:
  427.         nop
  428.         leave
  429.         .cfi_def_cfa 7, 8
  430.         ret
  431.         .cfi_endproc
  432. .LFE2533:
  433.         .size        _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim, .-_ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
  434.         .section        .text._ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv,"axG",@progbits,_ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv,comdat
  435.         .align 2
  436.         .weak        _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
  437.         .type        _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv, @function
  438. _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv:
  439. .LFB2534:
  440.         .cfi_startproc
  441.         pushq        %rbp
  442.         .cfi_def_cfa_offset 16
  443.         .cfi_offset 6, -16
  444.         movq        %rsp, %rbp
  445.         .cfi_def_cfa_register 6
  446.         movq        %rdi, -8(%rbp)
  447.         movq        -8(%rbp), %rax
  448.         popq        %rbp
  449.         .cfi_def_cfa 7, 8
  450.         ret
  451.         .cfi_endproc
  452. .LFE2534:
  453.         .size        _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv, .-_ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
  454.         .section        .text._ZSt8_DestroyIPiiEvT_S1_RSaIT0_E,"axG",@progbits,_ZSt8_DestroyIPiiEvT_S1_RSaIT0_E,comdat
  455.         .weak        _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
  456.         .type        _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E, @function
  457. _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E:
  458. .LFB2535:
  459.         .cfi_startproc
  460.         pushq        %rbp
  461.         .cfi_def_cfa_offset 16
  462.         .cfi_offset 6, -16
  463.         movq        %rsp, %rbp
  464.         .cfi_def_cfa_register 6
  465.         subq        $32, %rsp
  466.         movq        %rdi, -8(%rbp)
  467.         movq        %rsi, -16(%rbp)
  468.         movq        %rdx, -24(%rbp)
  469.         movq        -16(%rbp), %rdx
  470.         movq        -8(%rbp), %rax
  471.         movq        %rdx, %rsi
  472.         movq        %rax, %rdi
  473.         call        _ZSt8_DestroyIPiEvT_S1_
  474.         nop
  475.         leave
  476.         .cfi_def_cfa 7, 8
  477.         ret
  478.         .cfi_endproc
  479. .LFE2535:
  480.         .size        _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E, .-_ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
  481.         .section        .text._ZNSt15__new_allocatorIiEC2Ev,"axG",@progbits,_ZNSt15__new_allocatorIiEC5Ev,comdat
  482.         .align 2
  483.         .weak        _ZNSt15__new_allocatorIiEC2Ev
  484.         .type        _ZNSt15__new_allocatorIiEC2Ev, @function
  485. _ZNSt15__new_allocatorIiEC2Ev:
  486. .LFB2612:
  487.         .cfi_startproc
  488.         pushq        %rbp
  489.         .cfi_def_cfa_offset 16
  490.         .cfi_offset 6, -16
  491.         movq        %rsp, %rbp
  492.         .cfi_def_cfa_register 6
  493.         movq        %rdi, -8(%rbp)
  494.         nop
  495.         popq        %rbp
  496.         .cfi_def_cfa 7, 8
  497.         ret
  498.         .cfi_endproc
  499. .LFE2612:
  500.         .size        _ZNSt15__new_allocatorIiEC2Ev, .-_ZNSt15__new_allocatorIiEC2Ev
  501.         .weak        _ZNSt15__new_allocatorIiEC1Ev
  502.         .set        _ZNSt15__new_allocatorIiEC1Ev,_ZNSt15__new_allocatorIiEC2Ev
  503.         .section        .text._ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim,"axG",@progbits,_ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim,comdat
  504.         .weak        _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
  505.         .type        _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim, @function
  506. _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim:
  507. .LFB2614:
  508.         .cfi_startproc
  509.         pushq        %rbp
  510.         .cfi_def_cfa_offset 16
  511.         .cfi_offset 6, -16
  512.         movq        %rsp, %rbp
  513.         .cfi_def_cfa_register 6
  514.         subq        $32, %rsp
  515.         movq        %rdi, -8(%rbp)
  516.         movq        %rsi, -16(%rbp)
  517.         movq        %rdx, -24(%rbp)
  518.         movq        -24(%rbp), %rdx
  519.         movq        -16(%rbp), %rcx
  520.         movq        -8(%rbp), %rax
  521.         movq        %rcx, %rsi
  522.         movq        %rax, %rdi
  523.         call        _ZNSt15__new_allocatorIiE10deallocateEPim
  524.         nop
  525.         leave
  526.         .cfi_def_cfa 7, 8
  527.         ret
  528.         .cfi_endproc
  529. .LFE2614:
  530.         .size        _ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim, .-_ZNSt16allocator_traitsISaIiEE10deallocateERS0_Pim
  531.         .section        .text._ZSt8_DestroyIPiEvT_S1_,"axG",@progbits,_ZSt8_DestroyIPiEvT_S1_,comdat
  532.         .weak        _ZSt8_DestroyIPiEvT_S1_
  533.         .type        _ZSt8_DestroyIPiEvT_S1_, @function
  534. _ZSt8_DestroyIPiEvT_S1_:
  535. .LFB2615:
  536.         .cfi_startproc
  537.         pushq        %rbp
  538.         .cfi_def_cfa_offset 16
  539.         .cfi_offset 6, -16
  540.         movq        %rsp, %rbp
  541.         .cfi_def_cfa_register 6
  542.         subq        $16, %rsp
  543.         movq        %rdi, -8(%rbp)
  544.         movq        %rsi, -16(%rbp)
  545.         movq        -16(%rbp), %rdx
  546.         movq        -8(%rbp), %rax
  547.         movq        %rdx, %rsi
  548.         movq        %rax, %rdi
  549.         call        _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
  550.         nop
  551.         leave
  552.         .cfi_def_cfa 7, 8
  553.         ret
  554.         .cfi_endproc
  555. .LFE2615:
  556.         .size        _ZSt8_DestroyIPiEvT_S1_, .-_ZSt8_DestroyIPiEvT_S1_
  557.         .section        .text._ZNSt15__new_allocatorIiE10deallocateEPim,"axG",@progbits,_ZNSt15__new_allocatorIiE10deallocateEPim,comdat
  558.         .align 2
  559.         .weak        _ZNSt15__new_allocatorIiE10deallocateEPim
  560.         .type        _ZNSt15__new_allocatorIiE10deallocateEPim, @function
  561. _ZNSt15__new_allocatorIiE10deallocateEPim:
  562. .LFB2674:
  563.         .cfi_startproc
  564.         pushq        %rbp
  565.         .cfi_def_cfa_offset 16
  566.         .cfi_offset 6, -16
  567.         movq        %rsp, %rbp
  568.         .cfi_def_cfa_register 6
  569.         subq        $32, %rsp
  570.         movq        %rdi, -8(%rbp)
  571.         movq        %rsi, -16(%rbp)
  572.         movq        %rdx, -24(%rbp)
  573.         movq        -24(%rbp), %rax
  574.         leaq        0(,%rax,4), %rdx
  575.         movq        -16(%rbp), %rax
  576.         movq        %rdx, %rsi
  577.         movq        %rax, %rdi
  578.         call        _ZdlPvm@PLT
  579.         leave
  580.         .cfi_def_cfa 7, 8
  581.         ret
  582.         .cfi_endproc
  583. .LFE2674:
  584.         .size        _ZNSt15__new_allocatorIiE10deallocateEPim, .-_ZNSt15__new_allocatorIiE10deallocateEPim
  585.         .section        .text._ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_,"axG",@progbits,_ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_,comdat
  586.         .weak        _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
  587.         .type        _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_, @function
  588. _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_:
  589. .LFB2675:
  590.         .cfi_startproc
  591.         pushq        %rbp
  592.         .cfi_def_cfa_offset 16
  593.         .cfi_offset 6, -16
  594.         movq        %rsp, %rbp
  595.         .cfi_def_cfa_register 6
  596.         movq        %rdi, -8(%rbp)
  597.         movq        %rsi, -16(%rbp)
  598.         nop
  599.         popq        %rbp
  600.         .cfi_def_cfa 7, 8
  601.         ret
  602.         .cfi_endproc
  603. .LFE2675:
  604.         .size        _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_, .-_ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
  605.         .text
  606.         .type        _Z41__static_initialization_and_destruction_0ii, @function
  607. _Z41__static_initialization_and_destruction_0ii:
  608. .LFB2710:
  609.         .cfi_startproc
  610.         pushq        %rbp
  611.         .cfi_def_cfa_offset 16
  612.         .cfi_offset 6, -16
  613.         movq        %rsp, %rbp
  614.         .cfi_def_cfa_register 6
  615.         subq        $16, %rsp
  616.         movl        %edi, -4(%rbp)
  617.         movl        %esi, -8(%rbp)
  618.         cmpl        $1, -4(%rbp)
  619.         jne        .L31
  620.         cmpl        $65535, -8(%rbp)
  621.         jne        .L31
  622.         leaq        _ZStL8__ioinit(%rip), %rax
  623.         movq        %rax, %rdi
  624.         call        _ZNSt8ios_base4InitC1Ev@PLT
  625.         leaq        __dso_handle(%rip), %rax
  626.         movq        %rax, %rdx
  627.         leaq        _ZStL8__ioinit(%rip), %rax
  628.         movq        %rax, %rsi
  629.         movq        _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rax
  630.         movq        %rax, %rdi
  631.         call        __cxa_atexit@PLT
  632. .L31:
  633.         nop
  634.         leave
  635.         .cfi_def_cfa 7, 8
  636.         ret
  637.         .cfi_endproc
  638. .LFE2710:
  639.         .size        _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
  640.         .type        _GLOBAL__sub_I__Z4getvv, @function
  641. _GLOBAL__sub_I__Z4getvv:
  642. .LFB2711:
  643.         .cfi_startproc
  644.         pushq        %rbp
  645.         .cfi_def_cfa_offset 16
  646.         .cfi_offset 6, -16
  647.         movq        %rsp, %rbp
  648.         .cfi_def_cfa_register 6
  649.         movl        $65535, %esi
  650.         movl        $1, %edi
  651.         call        _Z41__static_initialization_and_destruction_0ii
  652.         popq        %rbp
  653.         .cfi_def_cfa 7, 8
  654.         ret
  655.         .cfi_endproc
  656. .LFE2711:
  657.         .size        _GLOBAL__sub_I__Z4getvv, .-_GLOBAL__sub_I__Z4getvv
  658.         .section        .init_array,"aw"
  659.         .align 8
  660.         .quad        _GLOBAL__sub_I__Z4getvv
  661.         .hidden        DW.ref.__gxx_personality_v0
  662.         .weak        DW.ref.__gxx_personality_v0
  663.         .section        .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
  664.         .align 8
  665.         .type        DW.ref.__gxx_personality_v0, @object
  666.         .size        DW.ref.__gxx_personality_v0, 8
  667. DW.ref.__gxx_personality_v0:
  668.         .quad        __gxx_personality_v0
  669.         .hidden        __dso_handle
  670.         .ident        "GCC: (GNU) 12.2.1 20230111"
  671.         .section        .note.GNU-stack,"",@progbits
  672. sh-5.1$
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2023-2-18 10:25:24 | 显示全部楼层
有点奇怪。
这个应该只适用于stl的东西吧
<可以理解vector成容器在接收getv()函数的过程中,将返回值变成指针的形式,然后再解引用返回给了对应的数据.>
这个应该是对的,但不是所有类型都这样。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2023-2-19 13:19:31 | 显示全部楼层
我觉得在学习阶段可以适当探索底层,但是不能一刨到底,一下就把工程搞大了
我对返回的理解是,编译器把返回的结果打了个包,然后交给了接收它的变量,交接的时候当面清点,交接完这个包就丢掉了, 不要试图再去找这个包,就算找到了皮,里边的东西也不是你想要的了

还有,“定义了一个空的容器vector,没有赋值和构造”, 这句有问题,定义完成构造就必定完成
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-2-20 16:40:08 | 显示全部楼层
谢谢老大分享。。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-12 08:26

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表