<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 - Inconsistent Wunused-value warning with respect to macros"
href="https://bugs.llvm.org/show_bug.cgi?id=33580">33580</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Inconsistent Wunused-value warning with respect to macros
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>normal
</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>fuse001project@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Clang seems to ignore unused variables that are introduced by macro expansion.
$ cat -n test.c
1 #include <stdio.h>
2
3 int v[2];
4
5 #define M 2, 3
6
7 int main(void) {
8
9 v[0] = M;
10 printf("%d\n", v[0]);
11 v[0] = 5, 6;
12 printf("%d\n", v[0]);
13 return 0;
14
15 }
When compiling with `clang -Wunused-value test.c`, it reports
test.c:11:14: warning: expression result unused [-Wunused-value]
v[0] = 5, 6;
^
1 warning generated.
But in fact line 9 also contains an unused variable when M is expanded.
The tested clangs include: clang-3.8(tags/RELEASE_380/final) and
clang-4.0(tags/RELEASE_400/rc1) on Ubuntu; clang-4.0.0 (tags/RELEASE_400/final)
and Apple LLVM version 8.1.0 (clang-802.0.42) on MacOS.
gcc reports 2 unused variables when `-Wunused-value` is turned on (default
off).</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>