Uninitialized variables may have indeterminate values, as this answer to an earlier question points out. Is there a way to specify this indeterminate data to, say, repeat 0xDEADDEAD
? The indeterminate data is apparently compiler-specific, but it would always be nice to force it to be something easily recognizable.
Are there existing memory leak/corruption detection libraries allowing this? Overloading new
seems like a solution in some cases, but I'd rather not delve into that trickery myself.
The problem is that indeterminate values usually cause undefined behaviour of code, and rarely occurring run time bugs, so, for example, I'd like to spot if I've forgotten a memset()
somewhere in my code. Maybe even randomizing the indeterminate values could serve as a test bench.
In case this is not possible, are there better approaches to solve the problem?