Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Reminds me of some C-code I was told to port to Linux (if I remember correctly) some years back (probably in 2003). The code was from 1981 (it said so in the comment header).

Except for the fact the code was almost as old as I am (born in 1976) it turned out that the security check that the code was supposed to perform didn't actually execute.

Yepp, that's right, the code had been running for 30+ years doing nothing.

A friend of mine ended up doing the actual work so I don't know how the story ended but it's a good reminder to never assume _anything_ when you look for bugs.



This reminds me of an interesting event that occurred in my C++ class. During one of the assignments I looked at a peers code. I became convinced that the code was wrong. His code looked a little like this:

  bool operator<(.., ..)
  {
    return operator<(.., ..);
  }
He ran the code and it worked. I was confused.

Another student saw the teacher pass him and copied his implementation. His code didn't work. It gave the stack overflow error that I was expecting.

It turned out that the reason the guy had his code work in the first place was because it was never included in the program. He had put the code in his C++ file, but forgot to include it in his header. When the program compiled, it never knew his code existed.


In gcc this would not give a stack overflow error.


(Depending on your optimization settings)


Indeed. Please pardon me being nitpick-y and not adding to the conversation.


Just tried it, your right. However, this happened in Visual Studio.


I was teaching one of my good friend C way back in undergrad(1999). After explaining him about loops among other stuff...i asked him to print something in loop. And this is what he wrote

For(i=1 to 10) {then print i; } Today my friend is working as a techie ....senior mgr at his new company!


Seems like you need to improve your teaching abilities?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: