The problem may be the compiler optimizations. You should compare the assembly generated code.