Commit a7f67239 authored by Nils Erik Krumnack's avatar Nils Erik Krumnack
Browse files

fix EventLoop LeakCheck unit test ATLASG-1610

The problem was that the code needed to zero out the memory and with
newer compilers that requires `volatile` to be set to ensure the
zeroing out doesn't get optimized away.
parent 057c1e69
......@@ -19,7 +19,12 @@ namespace EL {
// Allocate the requested amount of memory.
if( m_leakBytes > 0 ) {
char* lostPointer = new char[ m_leakBytes ];
// This needs to be `volatile` and zeroed out to ensure the memory
// really gets allocated by the operating system. Without `volatile`
// the compiler is essentially allowed to optimize away the write,
// and the operating system isn't required to allocate it if it isn't
// written to.
volatile char* lostPointer = new volatile char[ m_leakBytes ];
for( int i = 0; i < m_leakBytes; ++i ) {
*lostPointer = 0;
++lostPointer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment