-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not
Description
Clang 17.0.6 and the latest git/main branch will issue "-Wunsequenced" for the following code sample,
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 explicitly state that the values and sides effects are explicitly sequenced, and provides the ordering. See C++20 [decl.init]p16.5 and [decl.init]p16.6.2.2, or the latest draft here and here
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should not