The other day a coworker called me to show a piece of my own code. I confess I got a little embarassed. The code was something like this:
func f(a, b uint){ // ... dif := a - b if (dif < 0) { // do stuff } } As it happens, "stuff" was never done. I expected the compiler to flag that comparison as an error ("You are testing to see if an unsigned value is negative. Please go back to school.") So I tried to code the same comparison in C and compiled using TCC, GCC and Microsoft compilers. Then did the same with C++ using GCC, Microsoft. Finally I tried in Pascal using the Free Pascal compiler. To my surprise only Pascal issued a warning. To be fair, MS compiler issued a warning as well, but only after I changed the project warning level to maximum. I imagine there is a really good reason for compilers not to flag this as an error, but I don't have a clue. Someone can tell me why this is so? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.