News for hackers. Stuff that matters.
Re:A common bug in published code by ignifero on Thursday April 21, 2011 @05:37PM (#2472493)
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*...

Re:A common bug in published code by benburleson on Thursday April 21, 2011 @07:58PM (#2472835)
That's why I write comparisons like

if (CONSTANT == variable)

Re:A common bug in published code by klochner on Thursday April 21, 2011 @08:36PM (#2472913)
Re:A common bug in published code by Splines on Thursday April 21, 2011 @11:39PM (#2473211)
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 by nostrademons on Friday April 22, 2011 @04:15AM (#2473546)
I personally like Yoda Conditions, but a few coworkers have pointed out that any linter worth its salt will catch an = inside a conditional, so this doesn't actually gain much in safety. I've stopped using them because there a large number of coworkers find them confusing.
Re:A common bug in published code by derleth on Thursday April 21, 2011 @08:37PM (#2472914)
Re:A common bug in published code by learner4life on Thursday April 21, 2011 @08:14PM (#2472862)
Maybe I am feeling dense, but I do not understand what you are trying to point out. None except one are errors as they relate to embedded sql statements (where Equal To is the comparison operator).
Re:A common bug in published code by ignifero on Thursday April 21, 2011 @08:35PM (#2472910)
maybe we re seeing different results. mine have 8 incorrect assignments in the first page
Re:A common bug in published code by loumf on Thursday April 21, 2011 @08:10PM (#2472857)
The code is generating code for a different language -- the = is always in a string.