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

  • coder
    replied
    This general approach is good for things like packets, where you have some variable amount of data following a fixed-size header.

    Leave a comment:


  • NobodyXu
    replied
    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.

    Leave a comment:


  • sinepgib
    replied
    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".

    Leave a comment:


  • NobodyXu
    replied
    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.

    Leave a comment:


  • kreijack
    replied
    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.

    Leave a comment:


  • sdack
    replied
    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.

    Leave a comment:


  • amxfonseca
    replied
    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

    https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    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.

    Leave a comment:


  • Jannik2099
    replied
    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.

    Leave a comment:


  • kpedersen
    replied
    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

    https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

    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.

    Leave a comment:


  • amxfonseca
    replied
    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

    Leave a comment:

Working...
X