[llvm-bugs] [Bug 26130] New: build error for unused local variable with incomplete type
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 13 06:51:20 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26130
Bug ID: 26130
Summary: build error for unused local variable with incomplete
type
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: arnd at linaro.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160113/a63692b0/attachment.html>
More information about the llvm-bugs
mailing list