Two case labels have the same value

tx0/cpp:duplicate-casedefaultwarningreliability/control-flowdepth fastbug

What it finds

case 2: ... case 1 + 1:: two labels of one switch with the same value. A compiler rejects that, so in code that compiles it is a mistake made by a macro or found only in some configurations; in an editor it is found before compiling.

Values are worked out from integer and character literals, enumerators declared in the file and the arithmetic between them. An enumerator after a directive in its list, or one declared differently in other branches of a conditional directive, has no value here, and labels with a conditional directive between them are not compared, since they may never be compiled together.

From the rule's source, duplicate_case.rs.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:duplicate-case" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:duplicate-case] reason="..."

tx0 explain tx0/cpp:duplicate-case shows the same in the terminal. Found a false positive? Report it.