if(foo() && bar()) if foo is false, then bar will never be executed because the condition is automatically false.
Well, I wondered if C did this by default or different optimization levels and such..
GCC did this by default no matter what the optimization level, as did PCC(bsd C compiler).
Now, I'm just giving everyone a warning as to this behavior. I am almost for sure somewhere in my old code of millions of bugs, I was unaware of this.
This will probably not usually be a problem, as I can't even think of a decent example of a bug made by this.
but here is my shot at it..
Code: Select all
//shutdown code
//functions return 1 on error.
if(shutdown_terminals() || sync_disks()){
kprintf("An error occured shutting down, attempting to continue\n");
}
//....
Just saying all this to maybe aid someone out there trying to find a hard bug.