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

    <tr>
        <th>Summary</th>
        <td>
            clang 16.0.0.rc3: C99 implicit declaration false positive?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          h-vetinari
      </td>
    </tr>
</table>

<pre>
    I'm trying to package the LLVM 16 stack for conda-forge, and one of the last missing pieces of infrastructure I need to [recompile](https://github.com/conda-forge/cctools-and-ld64-feedstock/pull/58) with that stack is https://github.com/tpoechtrager/cctools-port/ (essentially due to the need to sign apple artefacts).

Things work fine for clang 14/15, however, I'm running into an error for clang 16.0.0-rc3 that I don't understand:
```
[...]/cctools/ld64/src/3rd/helper.c:45:5: error: call to undeclared function '__assert'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    __assert(msg, file, line);
    ^
1 error generated.
```

I did loosely follow the work on the C99 implicit declarations and their removal in clang 16, but I don't understand how this function can be picked up as undeclared when the respective file _does_ [include](https://github.com/tpoechtrager/cctools-port/blob/973.0.1-ld64-609/cctools/ld64/src/3rd/helper.c#L19) the required header (and glibc has been [declaring](https://github.com/bminor/glibc/blob/glibc-2.12/assert/assert.h#L80-L83) that function since forever).

I looked for related reports and found mainly #55489. Playing around from there, the interesting thing is that for a minimized example, things work fine (see [godbolt](https://godbolt.org/z/dnrcszzjY)). But I cannot figure out how this could break in the full version - the include is not hidden by a macro, I don't see how a function can be _un_-declared, etc. Perhaps I'm overlooking something obvious, but given the back and forth on this, I thought perhaps it's worth filing this issue nevertheless.

Looking at the clang 16 [release notes](https://github.com/llvm/llvm-project/blob/release/16.x/clang/docs/ReleaseNotes.rst): 
> The ``-Wimplicit-function-declaration`` and ``-Wimplicit-int`` warnings now default to an error in C99, C11, and C17. As of C2x, support for implicit function declarations and implicit int has been removed, and the warning options will have no effect. Specifying ``-Wimplicit-int`` in C89 mode will now issue warnings instead of being a noop.
>
> **NOTE**: We recommend that projects using configure scripts verify that the  results do not change before/after setting ``-Werror=implicit-function-declarations`` or ``-Wimplicit-int`` to avoid incompatibility with Clang 16.

And indeed, the project is configure based, but I'm unsure what part of the configuration could even cause this scenario that... I actually diffed `config.status` and there's no difference.



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUV11v47gV_TXMy4UFi_Lngx-czBgIkO4uuoMu-hRQ5JXEDUWqJGVP5tcXl5RipztNWiBxpIgi7zn3nENahKBbi3hg63u2_nInxtg5f-gWZ4zaCq_vaqdeD4-Mb3uI_lXbFqKDQcgX0SLEDuHp6R9_g3IDIQr5Ao3zIJ1VYtE43yLjDyCsAmcRXJPGGxEi9DoEmmvQKDHQI20bL0L0o4yjR3gEi6hoLba-9yhdP2iDbP2F8V0X4xBYdWT8xPip1bEb60K6nvHTu6VPUkbnTFgIqxZGbVaLBlGF6OQL46dhNIbx03rH-B4uOnYQOxEnGDrAB6vEwaHsohct-ptlBucj4ydgfIchoI1aGPMKakTCQdhnTEQ6iGEwCMJHbISMgfF9wZZf2PKYP7912rYBLs6_QKMtZmqNsC2UK8ZP5ZrI7dwFz1TFA-Qm-dFaYlbb6EBYQO-dv313UyyL5cLLKuN9BOUs49sIo1XoQxRWEepcyWY5_eTb9X1RFKkJM2jGT8Qs46fgJeOnyivGTx2aAX0hWXVcrVl1pN9cCV1IYQyxQAtKIzwqaEYro3YWGN8-P4sQkKjcsuoeHn__FR72-yQjIyJ6UA6sixDGgRgH3Q9GSx2vk-RpBV0H0s_ij3nMYh6zuBlDgBI-AIDr6rs-tMRrQ8LjD2C0Rcb3rLq_jmbrr_mmnIhu0aIXEVXxcwbT5yMorcA4F9C8QuOMcZekj9RsZ9M1YX6D9g4RMRE71B489u4sDGj71l2qtB5_3ldSC8ROhytVUlioEQYtX1DBOIAIt325dJir8RgGlFGfMfEBz8pheCZ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