https://bugs.llvm.org/show_bug.cgi?id=50219

            Bug ID: 50219
           Summary: Unable to use regular NULL as initializer for atomic
                    function pointer in C
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to