MCPcopy Create free account
hub / github.com/Kitware/CMake / test4

Function test4

Source/kwsys/testProcess.c:108–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static int test4(int argc, char const* argv[])
109{
110#ifndef CRASH_USING_ABORT
111 /* Prepare a pointer to an invalid address. Don't use null, because
112 dereferencing null is undefined behaviour and compilers are free to
113 do whatever they want. ex: Clang will warn at compile time, or even
114 optimize away the write. We hope to 'outsmart' them by using
115 'volatile' and a slightly larger address, based on a runtime value. */
116 int volatile* invalidAddress = 0;
117 invalidAddress += argc ? 1 : 2;
118#endif
119
120#if defined(_WIN32)
121 /* Avoid error diagnostic popups since we are crashing on purpose. */
122 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
123#elif defined(__BEOS__) || defined(__HAIKU__)
124 /* Avoid error diagnostic popups since we are crashing on purpose. */
125 disable_debugger(1);
126#endif
127 (void)argc;
128 (void)argv;
129 fprintf(stdout, "Output before crash on stdout from crash test.\n");
130 fprintf(stderr, "Output before crash on stderr from crash test.\n");
131 fflush(stdout);
132 fflush(stderr);
133#ifdef CRASH_USING_ABORT
134 abort();
135#else
136 assert(invalidAddress); /* Quiet Clang scan-build. */
137 /* Provoke deliberate crash by writing to the invalid address. */
138 *invalidAddress = 0;
139#endif
140 fprintf(stdout, "Output after crash on stdout from crash test.\n");
141 fprintf(stderr, "Output after crash on stderr from crash test.\n");
142 return 0;
143}
144
145static int test5(int argc, char const* argv[])
146{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…