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

    <tr>
        <th>Summary</th>
        <td>
            __func__ cannot share addresses with string literals in C
        </td>
    </tr>

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

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

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

<pre>
    The following program demonstrates this issue:
```c
#include<stdio.h>
int main(){
    static const char X[]="main";
    printf("%i\n",__func__=="main");
 printf("%i\n",X=="main");
}
```
Clang prints 1 then 0 with this program, when it should print 0 then 0.
> The identifier \_\_func\_\_ shall be implicitly declared by the translator as if, immediately following
the opening brace of each function definition, the declaration

> static const char \_\_func\_\_[] = "function-name";

> appeared, where function-name is the name of the lexically-enclosing function.

Section 6.4.2.2 "Predefined identifiers" Paragraph 1 ISO/IEC 9899:2024

Unlike C++, C doesn't say that \_\_func\_\_ can share addresses with string literals so `__func__=="main"` should be zero for the same reason that `X=="main"` is zero.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVEGP4zYP_TXKhRhDoe04PviQ8Uzw7elbYFtgbwFt0zFbWQokZafpry9kJ91Z7A5QxIGYWI98fI8ghSBny9yo8lmVLxu6xsn55n9k0ud6o5HE5JvODbfmt4lhdMa4N7FnuHh39jTDwLOzIXqKHCBOEkBCuLLKD0of1E6vT59-YC62N9eBVd6GOIjLJpW_Kn0QG2EmsQr3CmtVPSt9AAAIkaL00KcC0E_k4evKU-UvCnGFoMof9y9ebByXLKiwFFW2ywVsT6fxavvTKQF_wGJ9h3-M_fohSFUv75tU-tAaWrQRGwNsIU5sQcObxGnV5q6awhbe0juJECZ3NcOKAX2HZClv_gpJcxnYRhmFPaiyPaVvauYRQ5jIGOgYZL4Y6SWaGwzcG_I8QHdLGSF6ssFQdB4ogIyJgMwzD0KRze27r0of0n13YZtc7jz1DG4Epn6CVDaKszDwKFZSmBIlwFqQlr9W6vfjZw9_1cRqK6j8BRTio86TpZn_dfhdUrpcOLV319Ez_AABCQupJXbjEhv-S3oy5vbEtjcupO4eoEVtffjCa3e7rMgww8Tks-elVx7e2RAUInwmT2dPlwm28OnL_xUeP722UO_rWuUH1FisOX-3Rv5kaBU-L08LLQyOg1VYRQiU7KH4a2N7sslcz0DD4DkEDusohegTfSORPZkAwYHa6Q9nfKcfQ9Yx_M3ewej8IkpIAnmm4Oydx07_PO47nQRNwGwzNPlQ5zVtuNlWZa7LEnf5Zmq07rZDNfA4FkNd13W-1z3td_tyV3a5LmkjDWosdYUa86Iq8qzmsi-rYluVdVWOuFeF5pnEZMZ8mzPnz5tlkTTboq6KemOoYxOWPYVo-e2-ZhDT2vJNAj1113NQhTYSYvieJko03DzUSapaF_-bsGKh3Vy9aaYYLyHtNDwqPJ4lTtcu692s8Jjq3I-ni3d_cB8VHhd2QeHxTv9bg_8EAAD__wD1tBw">