Norcroft c 5.88 generates infinite loop
Dave Daniels (9035) 3 posts |
Hello all, xxxx B xxxx Closer inspection showed that it was a bug in my program but I am wondering if The actual code went something like this: extern int aaa(void); while (aaa != 0); The bug is that it should have said: while (aaa() != 0); I can see what is happening here. It has taken ‘aaa’ as a constant that xxxx B xxxx I would just put it down a mistake on my part if ‘aaa’ was variable Dave Daniels |
Jeffrey Lee (213) 6048 posts |
For comparison, clang doesn’t warn about the infinite loop, but it does warn about the comparison always being true: test.c:8:8: warning: comparison of function 'aaa' not equal to a null pointer is always true [-Wtautological-pointer-compare] while(aaa != 0); ^~~ ~ test.c:8:8: note: prefix with the address-of operator to silence this warning while(aaa != 0); ^ & test.c:8:8: note: suffix with parentheses to turn this into a function call while(aaa != 0); ^ () Applying either of the two suggested changes will remove the warning, with no other warnings being generated (this is with I’m not sure I’ve ever seen a C compiler warn about infinite loops. |
Dave Daniels (9035) 3 posts |
Hello Jeffrey, Dave Daniels |