[LLVMbugs] [Bug 1883] Overly strict error with initializer + cast
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Jan 8 16:06:53 PST 2008
http://llvm.org/bugs/show_bug.cgi?id=1883
snaroff at apple.com <snaroff at apple.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #2 from snaroff at apple.com 2008-01-08 18:06:53 ---
In C99 mode, clang is consistent with GCC. For example...
[snaroff:llvm/tools/clang] snarofflocal% ../../Debug/bin/clang comp-lit.c
-pedantic
comp-lit.c:4:24: error: initializer element is not constant
static struct Test t = (struct Test){0,0};
^~~~~~~~~~~~~~~~~~
1 diagnostic generated.
[snaroff:llvm/tools/clang] snarofflocal% cc -c comp-lit.c -std=c99
comp-lit.c:4: error: initializer element is not constant
In C90 mode, GCC appears to omit the type initializer error (which seems
bad)...
[snaroff:llvm/tools/clang] snarofflocal% ../../Debug/bin/clang -std=c90
comp-lit.c -pedantic
comp-lit.c:4:24: warning: compound literals are a C99-specific feature
static struct Test t = (struct Test){0,0};
^
comp-lit.c:4:24: error: initializer element is not constant
static struct Test t = (struct Test){0,0};
^~~~~~~~~~~~~~~~~~
2 diagnostics generated.
[snaroff:llvm/tools/clang] snarofflocal% cc -c comp-lit.c -pedantic
comp-lit.c:4: warning: ISO C90 forbids compound literals
btw...even though the behavior was/is correct, this did expose a significant
bug. Expr::isConstantExpr() wasn't handling CompoundLiteralExpr's at all:-(
Since the default was "false", we were just lucking out. See commit r45764 for
more details.
--
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