Unverified Commit f126db64 authored by Chen Yufei's avatar Chen Yufei Committed by GitHub
Browse files

Log warning instead of fatal when parsing float get under/overflow (#4336)

* Log warning instead of fatal when parsing float get under/overflow.

For texts that resolve to infinity, under or overflow should be
accepted.

* Remove outdated unit test.

* empty commit to trigger ci
parent 1b567bf1
...@@ -347,7 +347,7 @@ inline static const char* AtofPrecise(const char* p, double* out) { ...@@ -347,7 +347,7 @@ inline static const char* AtofPrecise(const char* p, double* out) {
Log::Fatal("no conversion to double for: %s", p); Log::Fatal("no conversion to double for: %s", p);
} }
if (errno == ERANGE) { if (errno == ERANGE) {
Log::Fatal("convert to double got underflow or overflow: %s", p); Log::Warning("convert to double got underflow or overflow: %s", p);
} }
return end2; return end2;
} }
......
...@@ -103,11 +103,6 @@ TEST_F(AtofPreciseTest, CornerCases) { ...@@ -103,11 +103,6 @@ TEST_F(AtofPreciseTest, CornerCases) {
} }
} }
TEST_F(AtofPreciseTest, UnderOverFlow) {
double got = 0;
ASSERT_THROW(LightGBM::Common::AtofPrecise("1e+400", &got), std::runtime_error);
}
TEST_F(AtofPreciseTest, ErrorInput) { TEST_F(AtofPreciseTest, ErrorInput) {
double got = 0; double got = 0;
ASSERT_THROW(LightGBM::Common::AtofPrecise("x1", &got), std::runtime_error); ASSERT_THROW(LightGBM::Common::AtofPrecise("x1", &got), std::runtime_error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment