[LLVMbugs] [Bug 10231] New: no error on inline function with static variable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jun 30 13:16:24 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10231
Summary: no error on inline function with static variable
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: nlewycky at google.com
CC: llvmbugs at cs.uiuc.edu
C99 6.7.4 paragraph 3 reads:
"An inline definition of a function with external linkage shall not contain a
definition of a modifiable object with static storage duration, and shall not
contain a reference to an identifier with internal linkage."
which does not appear to be implemented by clang:
nlewycky at ducttape:~$ cat x.c
inline int* foo() {
static int x;
return &x;
}
nlewycky at ducttape:~$ clang x.c -std=c99 -Wall -pedantic -fsyntax-only
nlewycky at ducttape:~$
GCC notices this and offers a warning:
nlewycky at ducttape:~$ gcc x.c -std=c99 -fsyntax-only
x.c: In function ‘foo’:
x.c:2: warning: ‘x’ is static but declared in inline function ‘foo’ which is
not static
but I really think that warning should be an error (downgrading it to a warning
is fine as an extension so long as you go ahead and detect bad uses of it, such
as taking its address).
--
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