Fixed SF Clang build --- removed some undefined behavior