Skip to content

std::initializer_list transformation produces invalid code #647

@denis-gerasimov

Description

@denis-gerasimov
void f() {
  int v = std::max({1,2,3});
}

gets transformed into

void f()
{
  int v = const int __list4_20[3]{1, 2, 3};
  std::max(std::initializer_list<int>{__list4_20, 3});
}

which isn't valid C++.
Expected result is

void f()
{
  const int __list4_20[3]{1, 2, 3};
  int v = std::max(std::initializer_list<int>{__list4_20, 3});
}

https://cppinsights.io/s/e8e9e992

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