Fix garbage value being returned with optimizations enabled