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

    <tr>
        <th>Summary</th>
        <td>
            #101853 breaks `extern "C" int main...` even when -Wmain is disabled
        </td>
    </tr>

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

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

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

<pre>
    #101853 introduces a couple of problems. I guess, this boils down to marking the declaration of main() invalid in case it's declared with extern "C", but I may be wrong here.

The first problem is a clang crash: https://gcc.godbolt.org/z/dWETErhzM

The second one is a change of behavior of code that declares main() extern "C" (see my comment https://github.com/llvm/llvm-project/commit/37ec6e5f12afe4a37872bf28f280423696f39019#r145380228). This one still needs some work to create a standalone repro for, but I suspect that both issues are related to marking the declaration invalid.

The problem with both cases is that in some codebases the non-trivial amount of cleanup is necessary for this, but Clang doesn't allow to postpone the cleanup and retain the old behavior by just ignoring the diagnostic (-Wno-main). Even if the diagnostic is not issued, the issues above still manifest.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2O4ygQfhp8KcXC4N-DD73dHWkOe2upz2VTtpnGEAFOJvP0K5xkerZXWmkuSUTg4_srMAQ9W6KeVX-x6iXDLS7O92jox7Rkg1PXnglZ8KKtJGgbvVPbSAEQRredDIGb4OTdYGgNOXyDeaMQmHiGuOgAg9MmgHIXC9HBiv5D2xniQqBoNOgxamcTxIraMtEy0YG2ZzRagbYwYiDQkYkm3A-QgouOC9CPSN4CE-KZCZHuG7YI32DFKwwEF-_sDAt5yhl_Yfzp9vm2EEzah_igDHpXYtDOMHoMC5NPsMR4Ckw-MXFk4jiPYz47NTgTc-dnJo4_mTiq99e3V7_8_PsrfKDRWQXO0h17QTvvLg204Fk7n36PThHEBeNDVvjdgX-LAybaQATrFUa3rmTjV4Y6LtuQj25l4mjM-fF1OHn3ncbIxDEdTD4eZUNjTdVUCJyoRNm0jRgm0U6i5aWQdVdPsuNFx4T0RVnJloudUw5vKc8kK0RtDFgiFSC4leDi_EeKd_SEkQAhRLQKTdrs6eQdTM5_RhS2cKIx3uQPLi6gQ9hSpXzabzCS-r-23Pvxn2Afke792HFTfUKKYb9K2xvd5P2w_5OQrbOH6PVZowFc3Wbjno8htNspnbU0Ugjor0nF3uqHlOe9NspRsEw0EdAYd0nMTy7EU1KfLnhAoVXgKaK2-7Iz6rMRwxW-byGCnq3zvzRrnK0LUY-pAYd36w63jnQ5vJ7Jgp6-7kt0Xbz5qW5DSL_cHdz5Ed6KVk8U4t3DTPVSdbLDjPqiEbLlvBZVtvRNjcVUNXxoS9kSEZeyknVVCeR11WKX6V5wUfK2qHknuajyRo5lyZtCdjhUYzexktOK2uSpkGl-sp1OX_CyanhmcCAT9rdHCEuXG9k00dVL5vu9xcM2B1Zyo0MMnzBRR0O_PU2DJ_wIwGr-ZXq0jfts5XnOag6UnLssZOHwnpaTZ0oHHAypbPOm_-PZuvnLxPGu6dyLfwIAAP___8PCvA">