[Bug c++/123737] [15/16 Regression] GCC produces incorrect output when overloading operator, comma operator since r15-7089

jlame646 at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 21 04:42:27 GMT 2026


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

--- Comment #4 from Jason Liam <jlame646 at gmail dot com> ---
Note that we get the correct output for 129. Demo:
https://godbolt.org/z/eG69Tse1s

```
#include <cstddef>
#include <iostream>

struct Counter { // Counts number of `operator,` calls
  std::size_t count = 0;

  Counter& operator,(int) {
    ++count;
    return *this;
  }

  void finish(const char* label, std::size_t expected) const {
    std::cout << label << ": count=" << count << " expected=" << expected <<
"\n";
  }
};

int main() {


  Counter c129;
  c129, // an array of 130 zeros
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0;
  c129.finish("129", 129);
  return 0;
}
```

results in the correct output in both gcc and clang:

```
129: count=129 expected=129
```


More information about the Gcc-bugs mailing list