Announcement

Collapse
No announcement yet.

Linux 5.18 Switches From Zero Length Arrays To Flexible Array Members

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

  • Linux 5.18 Switches From Zero Length Arrays To Flexible Array Members

    Phoronix: Linux 5.18 Switches From Zero Length Arrays To Flexible Array Members

    Back in 2020 the Linux kernel tried adding flexible array members to replace zero length arrays but that time the code was reverted shortly thereafter. For Linux 5.18 the tree-wide change of replacing zero length arrays with C99 flexible array members was merged and appears to be all in good shape this time...

    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
    But now we remove the possibility of having some buggy and undefined behaviors in the codebase.

    Every one knows that this changes will only attract unskilled developers that don’t know how to program with real C. It’s unfair to the real programmers out there. Maybe even discriminatory.

    What’s next? Using Rust? Yeah, right…

    /s

    Comment


    • #3
      Originally posted by amxfonseca View Post
      But now we remove the possibility of having some buggy and undefined behaviors in the codebase.
      It wasn't undefined behavior of the GNU89 standard. Thats the good thing about making your own standards I suppose



      Following on from your sarcasm, it may very well attract actual C developers who were too disgusted by non-standard extensions.
      Better compiler portability is in reach!

      Lets just hope they won't use the non-standard RAII-like cleanup attribute extension. I always cringe when I see that in the wild.
      Last edited by kpedersen; 29 March 2022, 07:31 AM.

      Comment


      • #4
        Originally posted by kpedersen View Post

        It wasn't undefined behavior of the GNU89 standard. Thats the good thing about making your own standards I suppose
        That doesn't stop gcc from producing useless and misleading warnings about array bounds in these cases though - one shudders to imagine how many bugs slipped through because of this.

        Comment


        • #5
          Originally posted by kpedersen View Post

          It wasn't undefined behavior of the GNU89 standard. Thats the good thing about making your own standards I suppose

          I am not a well seasoned C programmer I must admit, especially when it comes to this kind of super specific behaviours . I don't mind, I have other strengths.

          The reason I said "undefined" was simply because the original author used similar wording on the documentation that explains why this change is being made. And this exact link was attached:

          https://git.kernel.org/pub/scm/linux...ea8dc11bb587cf

          But it looks that was only the case when the zero length array wasn't declared as the last member of the struct. Still, was quite an interesting read! And it's even nicer that the compiler can now help to prevent this.
          Last edited by amxfonseca; 29 March 2022, 07:54 AM.

          Comment


          • #6
            Originally posted by amxfonseca View Post
            What’s next? Using Rust? Yeah, right…

            /s
            They will never use Rust, no matter the sarcasm. They will sooner use C++ and turn everything into templates.

            Comment


            • #7
              Originally posted by kpedersen View Post
              [...]
              Lets just hope they won't use the non-standard RAII-like cleanup attribute extension. I always cringe when I see that in the wild.
              Other the fact that it is a non standard extension[*], there are other technical reasons to dislike it ?
              The first time that I faced this extension was when I played in systemd. And I found it very powerful and interesting. I think that it can make C code more clean.
              So I am interested to known possible downside.

              BR
              G.

              (*) Even tough it is a non standard exception, it is implemented in gcc, clang and icc... So only MSVC doesn't implement it.
              Last edited by kreijack; 29 March 2022, 04:42 PM.

              Comment


              • #8
                Originally posted by sdack View Post
                They will never use Rust, no matter the sarcasm. They will sooner use C++ and turn everything into templates.
                That's not going to happen.

                C++ is a mess and a massive footgun and Linus has explicitly stated multiple times that he will never accept C++ into Linux.

                Meanwhile, Rust in Linux is already under reviewed for the 5th time and soon the driver code can be written using Rust.

                Comment


                • #9
                  Originally posted by NobodyXu View Post

                  That's not going to happen.

                  C++ is a mess and a massive footgun and Linus has explicitly stated multiple times that he will never accept C++ into Linux.

                  Meanwhile, Rust in Linux is already under reviewed for the 5th time and soon the driver code can be written using Rust.
                  I agree 100% with you, but I think the mention to C++ was a way to say "Hell will freeze".

                  Comment


                  • #10
                    Originally posted by sinepgib View Post

                    I agree 100% with you, but I think the mention to C++ was a way to say "Hell will freeze".
                    You are right, I didn't look at the reference in the comment.

                    Comment

                    Working...
                    X