DEV Community

Discussion on: The uninitialized variable anathema: non-deterministic C++

Collapse
 
arj profile image
arj

Unfortunately there is also some compilers that initialize these values in DEBUG mode to zero or whatever the default value is and in RELEASE mode they are then filled with random values. The reason might also be re–use of registers and stack values.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

It may not be intentional that they are zero-initialized in DEBUG mode. They just happen to use freshed memory, and memory reuse is less aggressive.

I compile often with optmizations on, and still get lots of zeros in uninitialized areas.