public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108926] New: No warning for same expression in chain of | or & ?
@ 2023-02-24 14:21 dcb314 at hotmail dot com
  2023-02-24 14:22 ` [Bug c/108926] " dcb314 at hotmail dot com
  2023-02-27  8:38 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: dcb314 at hotmail dot com @ 2023-02-24 14:21 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-27  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 14:21 [Bug c/108926] New: No warning for same expression in chain of | or & ? dcb314 at hotmail dot com
2023-02-24 14:22 ` [Bug c/108926] " dcb314 at hotmail dot com
2023-02-27  8:38 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).