Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1865097 use explicit casts to compare doubles against integer limits #802

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/lib/ArrowChunkIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ ArrowChunkIterator::getCellAsInt64(size_t colIdx, int64 * out_data, bool rawData
return status;
}

if ((floatData > SF_INT64_MAX) || (floatData < SF_INT64_MIN))
if (floatData > static_cast<float64>(SF_INT64_MAX) || floatData < static_cast<float64>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for int64.");
Expand Down Expand Up @@ -408,7 +408,7 @@ ArrowChunkIterator::getCellAsInt64(size_t colIdx, int64 * out_data, bool rawData
case arrow::Type::type::DOUBLE:
{
double dblData = m_columns[colIdx].arrowDouble->Value(m_currRowIndexInBatch);
if ((dblData > SF_INT64_MAX) || (dblData < SF_INT64_MIN))
if (dblData > static_cast<float64>(SF_INT64_MAX) || dblData < static_cast<float64>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for int64.");
Expand Down Expand Up @@ -542,7 +542,7 @@ ArrowChunkIterator::getCellAsUint64(size_t colIdx, uint64 * out_data)
case arrow::Type::type::DOUBLE:
{
double dblData = m_columns[colIdx].arrowDouble->Value(m_currRowIndexInBatch);
if ((dblData > SF_UINT64_MAX) || (dblData < SF_INT64_MIN))
if (dblData > static_cast<double>(SF_UINT64_MAX) || dblData < static_cast<double>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for uint64.");
Expand Down
Loading