Optimizations based on uninitialized variables make me very nervous.
If uninitialized memory reads are transformed into don't-cares, then
checking tools like valgrind will no longer see the UMR (assuming that
the lack of initialization is a bug).

Did I understand that icc does this?  It seems like a dangerous practice.

Yes, it looks like icc does this. But so does gcc, see below. There is no "add" in the generated code.

John Regehr


[reg...@babel ~]$ cat undef.c
int foo (int x)
{
  int y;
  return x+y;
}
[reg...@babel ~]$ current-gcc -O3 -S -o - undef.c -fomit-frame-pointer
        .file   "undef.c"
        .text
        .p2align 4,,15
.globl foo
        .type   foo, @function
foo:
        movl    4(%esp), %eax
        ret
        .size   foo, .-foo
        .ident  "GCC: (GNU) 4.5.0 20091117 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Reply via email to