2 ms·
Uh, the unit test being executed before the first commit was failing. It's a logic error, not a syntax error. And I was using GCC, which is happy to assign val
by ctdonath 15y ago
Uh, the unit test being executed before the first commit was failing. It's a logic error, not a syntax error.
And I was using GCC, which is happy to assign values amid a more complex logical evaluation. Try: if ( x = y && p ) return -1;
- ajross 15y ago$ echo 'int foo(int x, int y, int p) { if(x=y&&p) return -1; return 0; }' > test.c $ gcc -Wall -c test.c test.c: In function ‘foo’: test.c:1:1: warning: suggest parentheses around assignment used as truth value [-Wparentheses] This warning has been there since at least gcc 2.x, I believe. I'm not making fun of you, really. But seriously: if you are spending 4 hours chasing bugs that can be trivially found by turning warnings on in your compiler, you have some process issues unrelated to C or PHP syntax.
- ctdonath 15y agoIt likes if ( (x = y) && p ) return -1; (No, I don't have the exact statement in question handy. It was more complicated than this example.)
- jeltz 15y agoYes, and that is because "(x == y) && p" should be written as"x == y && p" according to gcc. If you add the brackets gcc takes that as a sign that you really wanted to do an assignment.