Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid array member type with structured bindings #352

Closed
jakubdabek opened this issue Nov 28, 2020 · 1 comment
Closed

Invalid array member type with structured bindings #352

jakubdabek opened this issue Nov 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@jakubdabek
Copy link

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;
}
@andreasfertig
Copy link
Owner

Hello @jakubdabek,

thanks for reporting this issue! That is indeed terribly wrong. A fix is on its way.

Andreas

@andreasfertig andreasfertig added the bug Something isn't working label Nov 29, 2020
andreasfertig added a commit that referenced this issue Nov 30, 2020
Fixed #352: Reference to array in structured binding was invalid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants