[Bug c++/126898] New: [contracts] Postconditions incorrectly treat parameters in the left operand of a comma expression as ODR-used

"zheng.xianyuwang at gmail dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126898

            Bug ID: 126898
           Summary: [contracts] Postconditions incorrectly treat
                    parameters in the left operand of a comma expression
                    as ODR-used
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: c++-contracts, c++26, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zheng.xianyuwang at gmail dot com
  Target Milestone: ---

Consider the following example:

```
void f (bool b)
  post ((b, true))
{}
```

In the comma expression `(b, true)', the left operand `b' is a discarded-value
expression. Since a has non-volatile scalar type, no lvalue-to-rvalue
conversion is applied to it, so this use does not constitute an ODR-use.

Similar to the example in https://eel.is/c++draft/basic.def.odr#5.2.2.2:
```
int x, y;
int _ = ((cond ? x : y), 0);  // does not odr-use x or y
```
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.