<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - function attribute "diagnose_if" doesn't see const char *"
href="https://bugs.llvm.org/show_bug.cgi?id=38095">38095</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>function attribute "diagnose_if" doesn't see const char *
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>naruse@airemix.jp
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Following code has two functions with "dignose_if" function attribute.
Their difference is just whose argument is `char *` or `const char *`.
But `const char *` one doesn't show error.
Is this intended behavior?
```
% clang --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
% cat b.c
int scan_args(char *fmt)
__attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
return 0;
}
int scan_args_const(const char *fmt)
__attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
return 0;
}
int
main(int argc, char **argv) {
return scan_args("20") + scan_args_const("20");
}
```
Expected behavior:
```
% clang b.c
b.c:15:26: error: invalid format string
return scan_args("20") + scan_args_const("20");
^
b.c:2:20: note: from 'diagnose_if' attribute on 'scan_args':
__attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
^ ~~~~~~~~~
b.c:15:50: error: invalid format string
return scan_args("20") + scan_args_const("20");
^
b.c:8:20: note: from 'diagnose_if' attribute on 'scan_args_const':
__attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
^ ~~~~~~~~~
2 errors generated.
```
Actual behavior:
```
% clang b.c
b.c:15:26: error: invalid format string
return scan_args("20") + scan_args_const("20");
^
b.c:2:20: note: from 'diagnose_if' attribute on 'scan_args':
__attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
^ ~~~~~~~~~
1 error generated.
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>