Handle showpos bug in gcc libstc++ 4.2.
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Thu, 01 Aug 2013 16:26:07 -0700
changeset 10106 41f46a8e5a96
parent 10105 04ef86d43986
child 10108 d9fc1c7ebb10
Handle showpos bug in gcc libstc++ 4.2.
src/core/model/int64x64.cc
--- a/src/core/model/int64x64.cc	Thu Aug 01 09:35:13 2013 -0700
+++ b/src/core/model/int64x64.cc	Thu Aug 01 16:26:07 2013 -0700
@@ -39,7 +39,24 @@
 std::ostream &operator << (std::ostream &os, const int64x64_t &value)
 {
   int64_t hi = value.GetHigh ();
-  os << std::showpos << hi << std::noshowpos << ".";
+
+  // Save stream format flags
+  std::ios_base::fmtflags ff = os.flags ();
+
+  { // See bug 1737:  gcc libstc++ 4.2 bug
+    if (hi == 0)
+      { 
+	os << '+';
+      }
+    else
+      {
+	os << std::showpos;
+      }
+  }
+  
+  os << hi << ".";
+  os.flags (ff);  // Restore stream flags
+
   uint64_t low = value.GetLow ();
   uint8_t msd = MostSignificantDigit (~((uint64_t)0));
   do