https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123072

            Bug ID: 123072
           Summary: GCC produces incorrect evaluation in compound
                    assignment operator
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program produces incorrect output with gcc trunk. 
```
#include <array>
#include <iostream>

using namespace std;

array<int, 2> a;

array<int, 2>& f() {
    cout << "f" << endl;
    return a;
}

int g(int const x) {
    cout << "g " << x << endl;
    return x;
}

int main() {
    f() = { g(1), g(2) };
}
```
The wrong output produced by gcc is :
> f
g 1
g 2

Reply via email to