interesting C++ problem. Debug vs Release

Debug gives correct answer. Release gives incorrect answer