<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63573>63573</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang report error when compile with -D_FORTIFY_SOURCE=2
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Gcourage
</td>
</tr>
</table>
<pre>
testcase
```c
#include <stdio.h>
extern int printf(const char *format, ...);
int main() {
printf("Hello World\n");
return 0;
}
```
```bash
clang -O2 -D_FORTIFY_SOURCE=2 test_1.c
```
output:
```
extern int printf(const char *format, ...);
^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:111:17: note: expanded from macro 'printf'
__printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
^
/usr/include/features.h:398:31: note: expanded from macro '__USE_FORTIFY_LEVEL'
# define __USE_FORTIFY_LEVEL 2
^
test_1.c:3:12: error: expected ')'
/usr/include/x86_64-linux-gnu/bits/stdio2.h:111:17: note: expanded from macro 'printf'
__printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
^
/usr/include/features.h:398:31: note: expanded from macro '__USE_FORTIFY_LEVEL'
# define __USE_FORTIFY_LEVEL 2
^
test_1.c:3:12: note: to match this '('
/usr/include/x86_64-linux-gnu/bits/stdio2.h:111:16: note: expanded from macro 'printf'
__printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
^
test_1.c:3:12: warning: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C2x, con
flicting with a previous declaration [-Wdeprecated-non-prototype]
extern int printf(const char *format, ...);
^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:111:3: note: expanded from macro 'printf'
__printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
```
clang version:
```
clang version 15.0.5
Target: x86_64-unknown-linux-gnu
Thread model: posix
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
gcc 12.2 compile pass
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVt-PozYQ_mucl1EQ2AGSBx6yyWZb6aSVdu-H-oSMGcA9YyPb7Ob611eGbHYv2qaVWumuKDJkPJ755vswY-6cbDViQdIbku4XfPSdscWdMKPlLS4qU38rPDovuEMS70m8JVk8_8TpP2VSCzXWCITtnK-liTrCbk-z04hHj1aD1B4GK7VvCF0Lo50H0XELhG4bY3vuCd1BFEWEbgi7mZeGNT2XmtA1oRsg-ckO8BqKUPoLKmXgi7GqJulOE0rfBgEAi360GuKzjeT7i4LeIj4bK-662SQU1y0s7yks9-Xh_uHjr4ffysf7Tw-7W8L2FAJNZRKJK1HN6IfRE3aZ5F-zBCR9IZweRmcJPZxEIfRwXGdltloqqcfjstUjoYdKekfoYVKLBrm2SZKEMSdsC9p4DHc8DlzXWENjTQ89F9YAofkLuPyF3LKcTaXovgKh67L89Hh7pujD7efbD7CEJOAuy8_bcvtw91iWAf_fg2-Q-9Gim0CyzTqMyT8A-Q6GM2JCGUCNjdQI72Gll7jO0rItCyzRKbG1xp4QoPBYh7ShqNc0_z8pLq6fVZmr13XZXtB5Az33ogPfSTdLt_6vpMt-vHTXSXjmVkvdhkcOzaiFl0ZDjUJxy6fnZ-k7M3rgMFjjjf82IEgHNQ4WBQ9vu9TAlYIntE4a7cA0sAOu6-DmLU4-3AGHP9Ca5cAt79GjfRtPw44eQ0HC6Blto6TwUrdT_ik5Pkkzuu-wkfRm-eUVyVIbvTxHJen-p_mcsh_wHlw0lblrnUT6q87znRMkaRRH6TzzkdsWQ8eCU9mj_qrNs35T_uzXWeQ19KZGFbwH4-RxnnpENX8e73Y7kNp5rtSkY_A786tkReihFeJ9hpMT0h3Xtay5R-hH5WVYxbYQBeVWcZ-tLlJec7rW_aexFQISGlEQph-kQhi4c4u6YPWGbfgCiyRb55sVizds0RU5z7OqTlmdVnGeNCndZHFV8VXGNrzhlC9kQWPK4oyu4028WmXRqhJM1HG-SvI6E01OVjH2XKpIqac-MrZdSOdGLDKW5myheIXKTQc1SjU-wzQZDjrpfmGLsGZZja0jq1hJ591rFC-9wmLW2OJgrJ97Fzx3qM_FTRvu3ZPNYrSq6LwfXHh_6CHoJH03VpEwfZBOPb3cwjb8HYUPGybAC7tigv9nAAAA__-0eBFT">