[PATCH wayland 4/6] tests: Use volatile pointer for NULL dereference

Thiago Macieira thiago at kde.org
Mon Sep 3 05:16:40 UTC 2018


On Tuesday, 28 August 2018 23:17:13 PDT Daniel Stone wrote:
> Clang warns that it can silently discard a non-volatile write to a NULL
> pointer (perhaps it constitutes undefined behaviour?), and recommends

It is.

> changing it to volatile.

That doesn't help. It's still UB and can be discarded because you're not 
allowed to provoke UB. If you need to write to a whose value is identical to 
NULL, write assembly.

How about a raise(SIGSEGV) instead?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center





More information about the wayland-devel mailing list