[LLVMbugs] [Bug 11910] New: Storage-class extern inside function body on tentatively static symbols breaks later definitions
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Feb 2 12:46:25 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=11910
Bug #: 11910
Summary: Storage-class extern inside function body on
tentatively static symbols breaks later definitions
Product: clang
Version: 3.0
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: snaury at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
When a symbol is tentatively defined static, and later inside a function is is
declared extern, then it later confuses clang about its linkage. For example:
static int var;
int func() {
extern int var;
return var;
}
static int var = 0; /* static declaration of 'var' follows non-static
declaration */
The error message is wrong, because var is still tentatively static. Even more:
static int var;
int func() {
extern int var;
return var;
}
int var = 0;
The above example compiles, when it should actually give an error "non-static
declaration of 'var' follows static declaration". Compiling with -S shows that
linkage was somehow changed to external. However:
static int var;
int func() {
extern int var;
return var;
}
The above example compiles fine, however compiling with -S shows that linkage
of var is kept internal. It looks like extern in function body doesn't change
symbol linkage by itself, but something about previous declarations clearly
becomes changed/forgotten.
--
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