Login
You're viewing the ruby.social public feed.
  • Nov 25, 2026, 8:18 PM

    @bunny @complexmath One reason it is hard to avoid a de-facto rule of "the compiler may create incorrect, unrelated code when undefined behavior occurs" is that *assuming* undefined behavior does not occur typically allows compilers to do optimizations. Optimizations are in nature code-rewriting. If the compiler is making incorrect assumptions about which optimizations are safe, it is difficult or impossible to put bounds on what kinds of generated code could result.

    💬 1🔄 0⭐ 1

Replies

  • Nov 25, 2026, 8:39 PM

    @mcc@mastodon.social @complexmath@hachyderm.io However, where you allow the compiler to assume undefined behavior is on the creator of the standard. That any soundness goes out the window the moment you randomly scribble over memory is understandable, and unfortunately C is historically about randomly scribbling over memory. That 'a-b' can result in pretty much any code whatsoever when a and b are signed is completely different can of worms. And yes, I understand that assuming a-b to not overflow ever allows the compiler to make some stupid optimizations. I don't think such optimizations are are really worth it. It reminds me of the joke about the f00f bug

    i386: Hooowww mmmuuuch iiisss 2 + 2 ...
    Pentium: 5!
    i386: thhhatsss wwrrooonnnggg ...
    Pentium: but fast!

    💬 0🔄 0⭐ 0