• Troy@lemmy.ca
      link
      fedilink
      arrow-up
      36
      ·
      1 day ago

      I love hitting these things in the real world. Not the big, but the comment. You just know someone spent a fortune in time and company resources to never solve the problem and their frustration level was ragequit. But then something stupid like adding

      while (0){};

      Suddenly made it work and they were like, fuckit.

      Usually it’s a bug somewhere in a compiler trying to over optimize or something and putting the line in there caused the optimization not to happen or something. Black magic.

      The downside is that the compiler bug probably gets fixed, and then decades later the comment and line are still there…

      • GarlicToast@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        21 hours ago

        The real world case I remember also included a TODO to return and fix the code later. In a published scientific software. I wonder how many paper were messed up by this buggy software. As I looked at the code due to the amount of bugs I encountered.

        It’s been many years from publication, and to the surprise of no one, they did not return to fix it.

      • zea@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        9
        ·
        1 day ago

        And then the compiler updates to get better at spotting optimization opportunities and it blows up again

      • nogooduser@lemmy.world
        link
        fedilink
        English
        arrow-up
        12
        ·
        1 day ago

        I used to work on an old DOS product and we didn’t have a debugger so we used to have a DEBUG command line argument with

        if (DEBUG) printf(“debugging”);
        

        to try to see what was happening and the number of times that code alone fixed the problem was scary.

        • psycho_driver@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          1 day ago

          I mean . . . I still do this on my own stuff. If I’m interested in optimizing for speed I’ll do it as #ifdef instead of if ()

    • Smokeydope@lemmy.world
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      1 day ago

      The digital manifestation of the ghost in the machine. It likes playing with the bits that line occupies when you aren’t looking. Don’t touch its line.