if (__mod)
*__fptr++ = __mod;
- // [22.2.2.2.2] Table 58
+ // C++11 [facet.num.put.virtuals] Table 88
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 4084. std::fixed ignores std::uppercase
+ bool __upper = __flags & ios_base::uppercase;
if (__fltfield == ios_base::fixed)
- *__fptr++ = 'f';
+ *__fptr++ = __upper ? 'F' : 'f';
else if (__fltfield == ios_base::scientific)
- *__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
+ *__fptr++ = __upper ? 'E' : 'e';
#if _GLIBCXX_USE_C99_STDIO
else if (__fltfield == (ios_base::fixed | ios_base::scientific))
- *__fptr++ = (__flags & ios_base::uppercase) ? 'A' : 'a';
+ *__fptr++ = __upper ? 'A' : 'a';
#endif
else
- *__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
+ *__fptr++ = __upper ? 'G' : 'g';
*__fptr = '\0';
}
--- /dev/null
+// { dg-do run }
+// LWG 4084. std::fixed ignores std::uppercase
+// PR libstdc++/114862 std::uppercase not applying to nan's and inf's
+
+#include <sstream>
+#include <limits>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void
+test_nan()
+{
+ std::ostringstream out;
+ double nan = std::numeric_limits<double>::quiet_NaN();
+ out << std::fixed;
+ out << ' ' << nan << ' ' << -nan;
+ out << std::uppercase;
+ out << ' ' << nan << ' ' << -nan;
+ out << std::showpoint;
+ out << ' ' << nan << ' ' << -nan;
+ out << std::showpos;
+ out << ' ' << nan << ' ' << -nan;
+ VERIFY( out.str() == " nan -nan NAN -NAN NAN -NAN +NAN -NAN" );
+}
+
+void
+test_inf()
+{
+ std::ostringstream out;
+ double inf = std::numeric_limits<double>::infinity();
+ out << std::fixed;
+ out << ' ' << inf << ' ' << -inf;
+ out << std::uppercase;
+ out << ' ' << inf << ' ' << -inf;
+ out << std::showpoint;
+ out << ' ' << inf << ' ' << -inf;
+ out << std::showpos;
+ out << ' ' << inf << ' ' << -inf;
+ VERIFY( out.str() == " inf -inf INF -INF INF -INF +INF -INF" );
+}
+
+int main()
+{
+ test_nan();
+ test_inf();
+}