<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58581>58581</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang emits confusing error passing void** as first arg to  __sync_bool_compare_and_swap_8
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          tstellar
      </td>
    </tr>
</table>

<pre>
    Here is a reduced test case taken from:
https://github.com/389ds/389-ds-base/blob/db3e8c0b2c6c216afffc0149e7d8bacb2b5d6aff/ldap/servers/slapd/back-ldbm/db-mdb/mdb_import_threads.c#L3205

```
$ cat sync.c 
#include <stdint.h>
int
test(volatile void *addr, volatile void *old, volatile void *new)
{
    return __sync_bool_compare_and_swap_8((void**)addr, (int64_t)old, (int64_t)(new));
}

$clang -c -o sync.o sync.c
sync.c:6:57: error: incompatible integer to pointer conversion passing 'int64_t' (aka 'long') to parameter of type 'void *' [-Wint-conversion]
    return __sync_bool_compare_and_swap_8((void**)addr, (int64_t)old, (int64_t)(new));
                                                        ^~~~~~~~~~~~
sync.c:6:71: error: incompatible integer to pointer conversion passing 'int64_t' (aka 'long') to parameter of type 'void *' [-Wint-conversion]
    return __sync_bool_compare_and_swap_8((void**)addr, (int64_t)old, (int64_t)(new));
                                                                      ^~~~~~~~~~~~~~
2 errors generated.
```
Is clang correct to emit an error here? Should it emit a different error?  gcc does not emit an error for this.  I think real problem is that the first argument is supposed to be a pointer to an integer type, but it's accepting void** and then complaining because the 2nd and third arguments are supposed to match the pointee type.  It's confusing, though, because if you look at the function signature, the second and third arguments are supposed to be integers.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVU2PnDgQ_TX0pdQITNN0Hzj0ZDLaSHvbwx6RPwpw2tjINhPNv98ydM9MNtFmFWm1lyCDXS676rlemRJOvbS_oUfQATh4VItEBRF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