Only do the deliberate crash via undefined behaviour (which the compiler
is quite right to warn us about!) if raise() isn't available.
The pointer needs to be volatile otherwise the compiler is free to remove
the store.
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
int
main (int argc, char **argv)
{
- char *p;
-
_dbus_disable_crash_handling ();
#ifdef HAVE_RAISE
raise (SIGSEGV);
+#else
+ {
+ volatile char *p = NULL;
+ *p = 'a';
+ }
#endif
- p = NULL;
- *p = 'a';
-
+
return 0;
}