Live data from Hacker News

A common bug in published code

google.com

51–60 of 79 posts

Re: A common bug in published code

#51
post #13

Someone should write a tool that scrapes these results and automatically files bugs at the associated bug trackers for open-source projects.

I've been thinking of doing something and i'm looking for people to work with! Notes here: http://memeschemes.com/code_search/

A bug in that program would certainly be wonderful. Have fun when it files a few million unnecessary bug reports while you're sleeping.

Re: A common bug in published code

#54

Earlier quoted context omitted.

I've been thinking of doing something and i'm looking for people to work with! Notes here: http://memeschemes.com/code_search/

A bug in that program would certainly be wonderful. Have fun when it files a few million unnecessary bug reports while you're sleeping.

Have it require approval for each bug report. While it isn't as fast as a fully automatic bug finding system, it is faster than a manual find and file. Plus it takes care of those situations where it was intended(poor coding, but it works).

Re: A common bug in published code

#56

A-mazing Also, notice the difference in number of results between C and C++ below: http://www.google.com/codesearch?hl=en&lr=&q=if%5Cs*... vs http://www.google.com/codesearch?hl=en&lr=&q=if%5Cs*...

That's why I write comparisons like if (CONSTANT == variable)

I know it's safer, but personally I find it harder to read. Especially if the constant is a #define or enum and is similar in format to the variable in question.

Re: A common bug in published code

#57

One would hope at some point a tool would warn you about this since clearly it could optimize (int) Math.random() to just 0. [queue debate about tools that hold your hands vs understanding what you are actually writing] I wonder if they did the search for if (x = y) bug pre-gcc-4.x-warn what sort of numbers they would get.

I believe this is the tool you are looking for.

http://findbugs.sourceforge.net/bugDescriptions.html#RV_01_T...

Re: A common bug in published code

#58
post #13

Someone should write a tool that scrapes these results and automatically files bugs at the associated bug trackers for open-source projects.

I've been thinking of doing something and i'm looking for people to work with! Notes here: http://memeschemes.com/code_search/

I've had some similar ideas myself, consider me interested. I've written some (very little) code to search projects among the big open source hosts (SF, Google, Github etc). Also have a nice domain for it.

Re: A common bug in published code

#59

the main cause here is that randomness is hard to test so that code was just assumed to be correct. With randomness you can never be sure, http://www.random.org/analysis/

Yes, but... (int)Math.random() always returns zero. A little suspicious.

You can never be sure the next one won't be a 1!

Re: A common bug in published code

#60

Apparently, python only has 5 instances of the corresponding error: http://www.google.com/codesearch?hl=en&lr=&q=\s%2Bin... Python-Java flame-war, anyone?

Clearly, PHP is a better language than both: int rand($min, $max)

ducks

All joking aside, I'm just pointing out the absurdity of comparing one language to another based on how easy it is to shoot oneself in the foot.

Post reply on HN