Skip to content

Tests: Prevent compiler optimizing away test code in CTestTestCrash

William R. Dieter requested to merge williamr/cmake:no-opt-crash into master

The CTestTestCrash tries to force a crash by dereferencing a NULL pointer. The oneAPI 2021.4 C compiler notices that the pointer and the value fetched from the pointer are never used and optimizes away the dereferencing of the NULL pointer, which prevents the crash, causing the test to fail.

This change adds the volatile keyword the pointer to prevent the compiler optimizing it away. Removing a reference to a volatile variable is illegal because access to a volatile variable could have side effects not observable by the compiler.

Edited by Brad King

Merge request reports

Loading