https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71983
Bug ID: 71983
Summary: "error: initializer element is not constant" only with
-O0
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: k2k at narod dot ru
Target Milestone: ---
Got error "error: initializer element is not constant" when following code is
compiled with '-O0'
int main(void)
{
static const int a = 1;
static const int b = 2;
static const int c = a + b;
return c;
}
If same code is compiled with -O1, -O2, -O3, -Ofast or even -Og, no errors and
no warnings are generated.