[LLVMbugs] [Bug 15071] New: redefinition of enumerator in enum not issuing an error
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jan 25 11:24:09 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=15071
Bug #: 15071
Summary: redefinition of enumerator in enum not issuing an
error
Product: clang
Version: 3.1
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: madler at alumni.caltech.edu
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang is not catching a redefinition of an enumerator in C if, for example, one
of them is inside of a struct. Example code:
#include <stdio.h>
struct q {
enum {
A,
B
} foo;
};
enum p {
B,
C
};
int main(void)
{
printf("B = %d\n", B);
return 0;
}
Compiling this with clang results in no error. It will print that B is either
zero or one, depending on which definition appears last in the source file.
If I remove the struct from around the first enum, then I get the expected:
clang-enum-bug.c:11:5: error: redefinition of enumerator 'B'
This had me going for while hunting down a bug where I had inadvertently used
the same enumerator in two different places, but the compiler didn't catch it.
I am using:
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list