Announcement

Collapse
No announcement yet.

Linux 5.3 Enables "-Wimplicit-fallthrough" Compiler Flag

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linux 5.3 Enables "-Wimplicit-fallthrough" Compiler Flag

    Phoronix: Linux 5.3 Enables "-Wimplicit-fallthrough" Compiler Flag

    The recent work on enabling "-Wimplicit-fallthrough" behavior for the Linux kernel has culminated in Linux 5.3 with actually being able to universally enable this compiler feature...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Good flag, these can slip through all the time

    Comment


    • #3
      So they don't use -Wextra by default?

      Comment


      • #4
        Surprising that it took so long. This was known to be a source of bugs for decades. For example, Java also introduced a safe switch just recently.

        Comment


        • #5
          Does not the Linux kernel have any commit hook or something that gets ran that does static code analysis?

          Comment


          • #6
            Originally posted by caligula View Post
            Surprising that it took so long. This was known to be a source of bugs for decades. For example, Java also introduced a safe switch just recently.
            and with Go fallthrough is explicit, though I have not yet come across a reason to use it myself

            Comment


            • #7
              Originally posted by atomsymbol
              The Linux kernel contains extra switch statements because it isn't written in a programming language with dynamic dispatch (runtime dispatch).
              Extra switch statements? Can you elaborate on why you think Java has both, the C style switches and dynamic dispatch?

              Comment


              • #8
                Originally posted by atomsymbol

                Expressing the semantics of object.method(arg) in C means to write code like:
                • switch(object->type) { case T1: S1; case T2: S2; }
                • if(object->type == T1) S1; else if(object->type == T2) S2;
                • method_table[object->type](object, arg)
                [FONT=arial, helvetica, sans-serif]C codes contain groups of expressions/statements involving switches, ifs or method-tables that are semantically equivalent to dynamic dispatch expressions in other languages.
                Cool story bro, but it doesn't work that way (two first two examples). The whole point of methods is that you can implement new cases without changing the switch logic. So it's definitely not equivalent. The main difference is the dependency inversion.

                Comment

                Working...
                X