News for hackers. Stuff that matters.
Re:Never trust a system that seems to be working by aidenn0 on Monday October 17, 2022 @07:38PM (#33241039)
My favorite was C code that was roughly (all functions and variables h:

  int bar;
  
  ...
  foo()
  {
    if(bar) {
      doX();
    else
      doY();
    }
  }
Note that uninitialized globals in C are implicitly zero-initialized.

doY() had been broken for years but nobody ever set bar to be true; doX() was nevertheless being called. Setting bar to zero caused the buggy doY() to happen. Setting bar to one seemed to work, but would occasionally segfault.

Then someone explicitly initialized bar and got a linker error. Turns out in ye olden days of C, before "extern" was a thing there was a feature where variables that were initialized in no more than one compilation unit would be all coalesced by the linker. Before doY was broken, someone defined a function named bar, which then caused bar to have a non-zero (i.e. true) value. Someone later added some broken feature to "doY" and it passed all the tests because changing doY() didn't have any effect.

Re:Never trust a system that seems to be working by blep_ on Monday October 17, 2022 @08:07PM (#33241313)
You're missing the } and { around your else, btw. I'm only mentioning that because I immediately saw it and got ready to read a horrifying story involving the text "#define else".
Re:Never trust a system that seems to be working by aidenn0 on Monday October 17, 2022 @11:58PM (#33242804)
oh gosh I am.
Re:Never trust a system that seems to be working by hinkley on Tuesday October 18, 2022 @12:43AM (#33243060)
I thought that was the bug on my first read. Naming collisions suck.