From 1bb56544ae15be58fabe3af820d9a7ce5028da3e Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Tue, 8 Oct 2019 09:10:18 +0000 Subject: [PATCH] Fix undefined in printf-test Fixes "signed integer overflow" in PrintfTest.Length This occurs in `TestLength("ll")`, since its minimum value minus one does not fit in long long. --- test/printf-test.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/printf-test.cc b/test/printf-test.cc index cd9950d1..d8fbc964 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -337,7 +337,9 @@ template void TestLength(const char* length_spec) { TestLength(length_spec, -42); TestLength(length_spec, min); TestLength(length_spec, max); - TestLength(length_spec, static_cast(min) - 1); + long long long_long_min = std::numeric_limits::min(); + if (static_cast(min) > long_long_min) + TestLength(length_spec, static_cast(min) - 1); unsigned long long long_long_max = max_value(); if (static_cast(max) < long_long_max) TestLength(length_spec, static_cast(max) + 1);