Skip to content

Invalid array member type with structured bindings #352

@jakubdabek

Description

@jakubdabek

Example code:

struct Foo {
  int a[5];
  float b[];
};

int main()
{
  Foo foo{{10}, {}};
  auto [a1, b1] = foo;
  const auto& [a2, b2] = foo;
}

And output:

struct Foo
{
  int a[5];
  float b[];
  // inline constexpr Foo(const Foo &) noexcept = default;
};
int main()
{
  Foo foo = {{10, 0, 0, 0, 0}, {}};
  Foo __foo9 = Foo(foo);
  int [5]& a1 = __foo9.a; // invalid declaration, should be `int (&a1)[5] = ...`
  float []& b1 = __foo9.b;
  const Foo & __foo10 = foo;
  int const[5]& a2 = __foo10.a;
  float const[]& b2 = __foo10.b;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions