Issue 83474
Summary [clang] False positive "-Wunsequenced" for C++20 parenthesized initializer lists
Labels clang
Assignees
Reporter vapdrs
    Clang 17.0.6 and the latest git/main branch will issue "-Wunsequenced" for the following code sample,

```c++
int val = 0;
struct S { int a; int b; };

int paren_list_init[](val++, val++);
int direct_list_init[]{val++, val++};

S paren_list_init_s(val++, val++);
S direct_list_init_s{val++, val++};
```

for only the C++20 parenthesized initializer lists, even though both are sequenced operations.

```
$ guix shell clang -- clang -c -o /dev/null -Wunsequenced -std=c++20 test.cpp 
test.cpp:4:26: warning: multiple unsequenced modifications to 'val' [-Wunsequenced]
    4 | int paren_list_init[](val++, val++);
      |                          ^ ~~
test.cpp:7:24: warning: multiple unsequenced modifications to 'val' [-Wunsequenced]
    7 | S paren_list_init_s(val++, val++);
      | ^      ~~
2 warnings generated.

```

I believe this to be a false positive because the C++20 parenthesized initializer lists added in [p0960r3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html) explicitly state that the values and sides effects are explicitly sequenced, and provides the ordering. See C++20 [decl.init]p17.5 and [decl.init]p17.6.2.2, or the latest draft [here](https://www.eel.is/c++draft/dcl.init#general-16.5) and [here](https://www.eel.is/c++draft/dcl.init#general-16.6.2.2)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to