Post by Paul Eggert- -Wduplicated-branches complained about three false positives,
In Emacs, I found -Wduplicated-branches to be useless and I disabled it.
Since it's finding only false alarms in grep, too, I suggest that we disable
it by default at the Gnulib level. My impression is that for GNU code,
-Wduplicated-branches is mostly just the compiler saying "Look how smart I
am!" rather than something that's helpful in finding real bugs.
Hi Paul,
I'm inclined to wait for more exposure, and/or to let projects disable
it themselves, since two of the three instances it flagged in grep
were odd enough that I feel they benefit from the added attention:
src/kwset.c:759: ptrdiff_t ret = (IGNORE_DUPLICATE_BRANCH_WARNING
src/kwset.c-760- (kwset->trans
src/kwset.c-761- ? bmexec_trans (kwset, text, size)
src/kwset.c-762- : bmexec_trans (kwset, text, size)));
--
src/kwset.c:908: return (IGNORE_DUPLICATE_BRANCH_WARNING
src/kwset.c-909- (kwset->trans
src/kwset.c-910- ? acexec_trans (kwset, text, size, kwsmatch, longest)
src/kwset.c-911- : acexec_trans (kwset, text, size,
kwsmatch, longest)));
In those cases, the duplication is tied to compiler optimization
internals, which makes me think we should have a test to ensure that
this very unusual (and kludgey-feeling) technique is still required.
I.e., it feels like a technique that a compiler optimizer may perform
on its own, rendering this duplication unnecessary.