Unable to use regular NULL as initializer for atomic function pointer in C #49563
Labels
bugzilla
Issues migrated from bugzilla
c11
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
rejects-valid
Extended Description
$ cat test-atomic.c
typedef void (fp)(void);
_Atomic fp ptr1 = ((void()(void))0);
_Atomic fp ptr2 = ((void*)0);
$ gcc -c test-atomic.c -Wall -Wextra
$ clang -c test-atomic.c
test-atomic.c:3:19: error: initializer element is not a compile-time constant
_Atomic fp ptr2 = ((void*)0);
^~~~~~~~~~
1 error generated.
When initiailizing an _Atomic function pointer, which is a pointer to a function, clang errors out when initializing it to the common NULL define (which often expands to ((void*)0) in C). Using 0 cast to the right function pointer type works.
GCC accepts the construct without warnings.
The text was updated successfully, but these errors were encountered: