On Mon, 3 May 2021, Liu Hao wrote:

在 2021-05-03 20:52, Martin Storsjö 写道:
On Mon, 3 May 2021, Christian Franke wrote:

Would plain '... = 0' without cast also work ? IIRC it should since C89 :-)

That doesn't work either - clang seems to consider the cast (either implicit or explicit) between a integer or pointer-to-integer and a pointer-to-function as something which isn't a compile time constant, in this context...


`0` itself is required to be a null pointer constant (not just `0`, but also any integer constant expression that equals zero, such as `1+1-2`). There is no cast in-between. [1]

[1] https://gcc.godbolt.org/z/Kv3edeW1j

Sure. However in practice, with e.g. code like this:

typedef void (*fp)(void);
_Atomic fp ptr1 = ((void(*)(void))0);
_Atomic fp ptr2 = ((void*)0);

Clang accepts ptr1 but errors out on ptr2: https://gcc.godbolt.org/z/3YW6EsGP4


In practice it shouldn't really matter, because as Jacek points out, we should be able to do without the atomics just fine in practice here.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to