diff --git a/src/learner.cc b/src/learner.cc index f7e51151f..d56f4ceb5 100644 --- a/src/learner.cc +++ b/src/learner.cc @@ -674,11 +674,15 @@ class LearnerImpl : public Learner { inline void LazyInitModel() { if (this->ModelInitialized()) return; // estimate feature bound + // TODO(hcho3): Change num_feature to 64-bit integer unsigned num_feature = 0; for (auto & matrix : cache_) { CHECK(matrix != nullptr); - num_feature = std::max(num_feature, - static_cast(matrix->Info().num_col_)); + const uint64_t num_col = matrix->Info().num_col_; + CHECK_LE(num_col, static_cast(std::numeric_limits::max())) + << "Unfortunately, XGBoost does not support data matrices with " + << std::numeric_limits::max() << " features or greater"; + num_feature = std::max(num_feature, static_cast(num_col)); } // run allreduce on num_feature to find the maximum value rabit::Allreduce(&num_feature, 1);