>>>>> "Michael" == Michael Matz <m...@suse.de> writes:

Michael> Not accepting
Michael>   /* And here we intentionally fall through because ... */
Michael> and forcing users to replace this by:
Michael>   /* fallthrough */
Michael> is not robust either.  It's actually actively lowering robustness of 
code, 
Michael> it creates work for programmers that will be regarded as pointless 
(and 
Michael> rightly so) and will merely lead to everybody disabling the warning 
(see 
Michael> our generated files)

We can't control what programmers might do.  My point is that accepting
too much is actively bad -- it hides errors.  If this somehow makes some
programmer fall down a slippery slope, well, that's their error, not
gcc's.

TBH I think it would be better not to parse comments at all.  Heuristics
are generally bad and this case and ensuing discussion is a great
demonstration of that.

The other day I built gdb with -Wimplicit-fallthrough.  I was surprised
to find that gcc rejected this:

        default:
          {
            complaint (&symfile_complaints,
                       _("Storage class %d not recognized during scan"),
                       sclass);
          }
          /* FALLTHROUGH */

          /* C_FCN is .bf and .ef symbols.  I think it is sufficient
             to handle only the C_FUN and C_EXT.  */
        case C_FCN:

Presumably without the comment heuristic, this would be accepted.

Michael> The point of warnings is to make code robust under the condition of 
not 
Michael> being a pain by giving zillions of false positives.

My experience so far is that it's not so bad.  gdb actually had comments
in most spots, they just required a quick pass to clean them up:

    https://sourceware.org/ml/gdb-patches/2016-09/msg00375.html

And, code bases in more dire straights can just disable the warning after all.

Tom

Reply via email to