This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/71983] New: "error: initializer element is not constant" only with -O0


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]