coder

  • 0 Posts
  • 35 Comments
Joined 1 year ago
cake
Cake day: June 23rd, 2023

help-circle






  • mrkite@programming.devtoC++@programming.devC++ Should Be C++
    ·
    6 months ago

    What are you talking about? Compilers can and do flag undefined behavior as errors. I recommend you read up on the documentation of any compiler.

    And I recommend you read Chris Latter's essay on UB.

    https://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html

    Where he gives plenty of examples of UB resulting in the compiler optimizing away safety and introducing security vulnerabilities silently. In part 3 he discusses the efforts clang has made to improve on this.

    He then went on to make Swift and says this: "Undefined behavior is the enemy of safety, and developer mistakes should be caught before software is in production."

    and

    "UB is an inseperable part of C programming, […] this is a depressing and faintly terrifying thing. The tooling built around the C family of languages helps make the situation less bad, but it is still pretty bad. The only solution is to move to new programming languages that dont inherit the problem of C."


  • mrkite@programming.devtoC++@programming.devC++ Should Be C++
    ·
    6 months ago

    It violates the principle of least surprise. You don't expect the compiler to delete your bounds checking etc.

    The way c and c++ define and use UB is like finding an error at compile time and instead of reporting it, the compiler decides to exploit it.