I remember when I was implementing a program for my thesis. In one of my routines the program did not behave as expected. I tested and tested again and again. I examined the logic of the routine and the programming logic looked fine, but it did not produce the expected result.
After thorough testing and thinking out of the box I found that a specific variable was being overwritten unexpectedly. In the declaration section of my routine this variable was preceded by another one. The code generated by the compiler was faulty: assignments to the preceding variable were overwriting the other variable.
That was really hard to find!
So do not take for granted that the programming environment you work with is 100% trustworthy.
If you are facing an unexplainable programming error then do some specific testing to see if the code generated by your programming environment is ok.