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

            Bug ID: 108926
           Summary: No warning for same expression in chain of | or & ?
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Static analyser cppcheck has the ability to produce a style warning
for the same identifier used multiple times in the same expression.

Two examples are

linux-6.2/drivers/spi/spi-sn-f-ospi.c:614:31: style: Same expression
'SPI_TX_OCTAL' found multiple times in chain of '|' operators.
[duplicateExpression]

Source code is

    ctlr->mode_bits = SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL
        | SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_OCTAL
        | SPI_MODE_0 | SPI_MODE_1 | SPI_LSB_FIRST;

linux-6.2/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c:68:10:
style: Same expression '0x3' found multiple times in chain of '&' operators.
[duplicateExpression]

If gcc had this ability, then two kernel bugs would be found easily.
I will check binutils and glibc.

This bug is related to 53357.

Reply via email to