circle icon indicating copy to clipboard operation
circle copied to clipboard

declaring multiple struct members with initializers within a single declaration does not compile

Open manxorist opened this issue 2 years ago • 0 comments

Circle (build 175) fails to compile the following C++ code:

struct foo {
  int a = 1, b = 2;
};
error: foo.cpp:2:11
expected ';' after declaration
  int a = 1, b = 2;
          ^

See https://godbolt.org/z/qqs8fMd1x (Circle) and https://godbolt.org/z/8o51T8cbd (Clang).

It works without initializers;

struct foo {
  int a, b;
};

It also works inside a function:

void foo() {
  int a = 1, b = 2;
}

I ran into this problem when trying to compile my project libopenmpt (https://github.com/OpenMPT/openmpt/) with Circle.

manxorist avatar Feb 01 '23 18:02 manxorist