Like I have this code. If I remove the bad function, the whole block run through, while if I bring it back, the whole block is not executed. 01234, none of these numbers printed out. This way, I cannot even find which line in the bad function is not working.
line 1: A for loop has 3 terms, initialization, termination and increment. You have four terms. I am surprised this even compiles. for(size_t i=0, I=C.size(); i<P.size(); ++i, ++I)
What is i<P.size() supposed to be? Is it supposed to be part of the termination condition? It's the third term, but is clearly not an increment.
@AbstractionAnon
The head of the for loop is just fine. Note the use of ,.
@northfly
What is the 'bad function'?
You need to check whether you have an index that is out of bounds. If you write out of bounds the stack may get corrupted and it is undefined what happens then.
If the loop isn't executing after you call the bad function then the loop condition is probably false. In other words, after executing the bad function, I suspect that P.size() <= 0. Try printing out P.size() just before the loop, or examine it in a debugger.