<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Unable to use regular NULL as initializer for atomic function pointer in C"
href="https://bugs.llvm.org/show_bug.cgi?id=50219">50219</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unable to use regular NULL as initializer for atomic function pointer in C
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>martin@martin.st
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>$ 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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>