about summary refs log tree commit diff
path: root/absl/strings/internal/str_format/arg.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/strings/internal/str_format/arg.cc')
-rw-r--r--absl/strings/internal/str_format/arg.cc36
1 files changed, 20 insertions, 16 deletions
diff --git a/absl/strings/internal/str_format/arg.cc b/absl/strings/internal/str_format/arg.cc
index 02646addec11..9feb22487932 100644
--- a/absl/strings/internal/str_format/arg.cc
+++ b/absl/strings/internal/str_format/arg.cc
@@ -267,38 +267,42 @@ bool ConvertIntArg(T v, const FormatConversionSpecImpl conv,
   using U = typename MakeUnsigned<T>::type;
   IntDigits as_digits;
 
-  switch (conv.conversion_char()) {
-    case FormatConversionCharInternal::c:
+  // This odd casting is due to a bug in -Wswitch behavior in gcc49 which causes
+  // it to complain about a switch/case type mismatch, even though both are
+  // FormatConverionChar.  Likely this is because at this point
+  // FormatConversionChar is declared, but not defined.
+  switch (static_cast<uint8_t>(conv.conversion_char())) {
+    case static_cast<uint8_t>(FormatConversionCharInternal::c):
       return ConvertCharImpl(static_cast<unsigned char>(v), conv, sink);
 
-    case FormatConversionCharInternal::o:
+    case static_cast<uint8_t>(FormatConversionCharInternal::o):
       as_digits.PrintAsOct(static_cast<U>(v));
       break;
 
-    case FormatConversionCharInternal::x:
+    case static_cast<uint8_t>(FormatConversionCharInternal::x):
       as_digits.PrintAsHexLower(static_cast<U>(v));
       break;
-    case FormatConversionCharInternal::X:
+    case static_cast<uint8_t>(FormatConversionCharInternal::X):
       as_digits.PrintAsHexUpper(static_cast<U>(v));
       break;
 
-    case FormatConversionCharInternal::u:
+    case static_cast<uint8_t>(FormatConversionCharInternal::u):
       as_digits.PrintAsDec(static_cast<U>(v));
       break;
 
-    case FormatConversionCharInternal::d:
-    case FormatConversionCharInternal::i:
+    case static_cast<uint8_t>(FormatConversionCharInternal::d):
+    case static_cast<uint8_t>(FormatConversionCharInternal::i):
       as_digits.PrintAsDec(v);
       break;
 
-    case FormatConversionCharInternal::a:
-    case FormatConversionCharInternal::e:
-    case FormatConversionCharInternal::f:
-    case FormatConversionCharInternal::g:
-    case FormatConversionCharInternal::A:
-    case FormatConversionCharInternal::E:
-    case FormatConversionCharInternal::F:
-    case FormatConversionCharInternal::G:
+    case static_cast<uint8_t>(FormatConversionCharInternal::a):
+    case static_cast<uint8_t>(FormatConversionCharInternal::e):
+    case static_cast<uint8_t>(FormatConversionCharInternal::f):
+    case static_cast<uint8_t>(FormatConversionCharInternal::g):
+    case static_cast<uint8_t>(FormatConversionCharInternal::A):
+    case static_cast<uint8_t>(FormatConversionCharInternal::E):
+    case static_cast<uint8_t>(FormatConversionCharInternal::F):
+    case static_cast<uint8_t>(FormatConversionCharInternal::G):
       return ConvertFloatImpl(static_cast<double>(v), conv, sink);
 
     default: