mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
Tests: Prevent compiler optimizing away test code in CTestTestCrash
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. Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
This commit is contained in:
committed by
Brad King
parent
41907da8ea
commit
7c90d00af9
@@ -1,6 +1,6 @@
|
||||
// causes a segfault
|
||||
int main()
|
||||
{
|
||||
int* ptr = 0;
|
||||
volatile int* ptr = 0;
|
||||
*ptr = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user