https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71885

--- Comment #26 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
For future reference here is a nice, short example from Bernd Edlinger:

markus@x4 tmp % cat lifetime-dse.cpp
#include <assert.h>
#include <stdlib.h>
#include <string.h>

struct A {
  A() {}
  void *operator new(size_t s) {
    void *ptr = malloc(s);
    memset(ptr, 0xFF, s);
    return ptr;
  }
  int value;
};

int main() {
  A *a = new A;
  assert(a->value == -1); /* Use of uninitialized value */
}

markus@x4 tmp % g++ -O2 -flifetime-dse=1 lifetime-dse.cpp
markus@x4 tmp % ./a.out

markus@x4 tmp % g++ -O2 -flifetime-dse=2 lifetime-dse.cpp
markus@x4 tmp % ./a.out
a.out: lifetime-dse.cpp:17: int main(): Assertion `a->value == -1' failed.
[1]    21394 abort      ./a.out

Reply via email to