On 3/2/20 22:02 UTC, Ben White wrote:
I’ve also been told that the g++ compiler will initialize all stack objects to zero when compiling for debug (the -g option).

Obviously you didn't try it.  g++ 9.2.1 does not do that.

$ cat foo.cpp
int g(int x, int y);

int f(int x)
{
        int y;
        return  g(x, y);  // uninit use of y
}

$ g++ -g -S foo.cpp
$ cat foo.s
        .file   "foo.cpp"
        .text
.Ltext0:
        .globl  _Z1fi
        .type   _Z1fi, @function
_Z1fi:
.LFB0:
        .file 1 "foo.cpp"
        .loc 1 4 1
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $32, %rsp
        movl    %edi, -20(%rbp)
        .loc 1 6 17
        movl    -4(%rbp), %edx   // -4(%rbp) is never initialized
        movl    -20(%rbp), %eax
        movl    %edx, %esi   // 2nd parameter to g
        movl    %eax, %edi
        call    _Z1gii
        .loc 1 7 1
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE0:
        .size   _Z1fi, .-_Z1fi
  [[snip]]
        .section        .debug_str,"MS",@progbits,1
.LASF1:
        .string "foo.cpp"
.LASF0:
        .string "GNU C++14 9.2.1 20190827 (Red Hat 9.2.1-1) -mtune=generic 
-march=x86-64 -g"
.LASF3:
        .string "_Z1fi"
.LASF2:
        .string "/home/user"
        .ident  "GCC: (GNU) 9.2.1 20190827 (Red Hat 9.2.1-1)"
        .section        .note.GNU-stack,"",@progbits
$


_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to