From f64e2d2daa64749995253f8ad00679ce74abdc1b Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 19 Aug 2020 11:02:00 +0200 Subject: [PATCH] GCC: ConsumeDurationNumber cannot be a constexpr Declaring base::ConsumeDurationNumber as constexpr is not valid, as it uses the BasicStringPiece::begin method, that is not constexpr. build error in GCC: ../../base/time/time.cc: In function ‘constexpr base::Optional base::{anonymous}::ConsumeDurationNumber(base::StringPiece&)’: ../../base/time/time.cc:67:63: error: call to non-‘constexpr’ function ‘const value_type* base::BasicStringPiece::begin() const [with STRING_TYPE = std::__cxx11::basic_string; base::BasicStringPiece::const_iterator = const char*; base::BasicStringPiece::value_type = char]’ 67 | StringPiece::const_iterator orig_start = number_string.begin(); | ~~~~~~~~~~~~~~~~~~~^~ Bug: 859294 Change-Id: Id987d003f66052848d7083bb33abc3acfd109b73 --- diff --git a/base/time/time.cc b/base/time/time.cc index 1b1a830..7c47419 100644 --- a/base/time/time.cc +++ b/base/time/time.cc @@ -61,8 +61,7 @@ // // Adapted from absl: // https://cs.chromium.org/chromium/src/third_party/abseil-cpp/absl/time/duration.cc?l=807&rcl=2c22e9135f107a4319582ae52e2e3e6b201b6b7c -constexpr Optional ConsumeDurationNumber( - StringPiece& number_string) { +Optional ConsumeDurationNumber(StringPiece& number_string) { ParsedDecimal res; StringPiece::const_iterator orig_start = number_string.begin(); // Parse contiguous digits.