<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - build error for unused local variable with incomplete type"
href="https://llvm.org/bugs/show_bug.cgi?id=26130">26130</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>build error for unused local variable with incomplete type
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arnd@linaro.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>A .c file containing "static const struct undefined_struct object;" with no
user of 'object' and no defintion for 'struct undefined_struct' produces a
warning and an error with clang:
test.c:1:38: warning: tentative definition of variable with internal linkage
has incomplete non-array type 'const struct undefined_struct'
[-Wtentative-definition-incomplete-type]
static const struct undefined_struct object;
^
test.c:1:21: note: forward declaration of 'struct undefined_struct'
static const struct undefined_struct object;
^
test.c:1:38: error: tentative definition has type 'const struct
undefined_struct' that is never completed
static const struct undefined_struct object;
^
test.c:1:21: note: forward declaration of 'struct undefined_struct'
static const struct undefined_struct object;
^
1 warning and 1 error generated.
This is inconsistent with gcc, which compiles the file without issuing any
warning, and that causes a build failure in one file of the linux-kernel
(drivers/staging/wilc1000/wilc_spi.c) that incorrectly has a variable
definition remaining after the type was removed. I have submitted a patch to
the kernel to remove that obviously unused variable, but it seems that issuing
a warning without the build error would be more consistent behavior for clang.
(gcc should probably also warn about this).</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>