KWSys: Avoid undefined behavior in Process crash tests
Clang is smart enough to recognize that "*(int*)0=0" invokes undefined behavior, warns, and produces an "undefined instruction". The message in commit "Avoid Clang optimizer bug in testProcess-[45]" (2010-07-02) is incorrect; this is not a Clang bug. It really is undefined behavior. Use "*(int*)1=0" to produce a crash instead.
This commit is contained in:
parent
a1a4a2cb6d
commit
70154efef8
|
@ -94,9 +94,8 @@ int test4(int argc, const char* argv[])
|
||||||
fprintf(stderr, "Output before crash on stderr from crash test.\n");
|
fprintf(stderr, "Output before crash on stderr from crash test.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#if defined(__APPLE__) && defined(__x86_64__) && defined(__OPTIMIZE__) \
|
#if defined(__clang__)
|
||||||
&& defined(__clang__)
|
*(int*)1 = 0; /* Clang warns about 0-ptr; undefined behavior. */
|
||||||
*(int*)1 = 0; /* Clang's optimizer produces bad code for 0-ptr. */
|
|
||||||
#else
|
#else
|
||||||
*(int*)0 = 0;
|
*(int*)0 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue