Skip to content

incorrect "error: initializer element is not constant" #2422

@edwintorok

Description

@edwintorok
Bugzilla Link 2050
Resolution FIXED
Resolved on Mar 12, 2010 00:57
Version unspecified
OS Linux

Extended Description

Using clang r47211, and llvm r47211 I cannot compile the code below.
gcc and icc compile the code without errors.

$ clang -fsyntax-only testcase-min.i
testcase-min.i:10:9: error: initializer element is not constant
{"OPEN", 1, &cdiff_cmd_open }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 diagnostic generated.

$ gcc -Wall -c testcase-min.i
testcase-min.i:9: warning: ‘commands’ defined but not used
$ icc -w2 -c testcase-min.i
testcase-min.i(9): remark #​177: variable "commands" was declared but never referenced
static struct cdiff_cmd commands[] = {
^

$ cat testcase-min.i
struct cdiff_cmd {
const char *name;
unsigned short argc;
int (*handler)();
};
static int cdiff_cmd_open() {
return 0;
}
static struct cdiff_cmd commands[] = {
{"OPEN", 1, &cdiff_cmd_open }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions