On 21/10/14 16:53 +0100, Joern Rennecke wrote:


libstdc++-v3:

2013-06-14  Joern Rennecke <joern.renne...@embecosm.com>

        * include/bits/locale_facets_nonio.h (__tm_small_int): typedef/define.
        (_M_extract_num): Templatize base type of __member argument.
        (_M_extract_name): Change type of __member argument to __tm_small_int&.
        * include/bits/locale_facets_nonio.tcc (_M_extract_via_format) <Z>:
        Change type of __tmp to __tm_small_int.
        (_M_extract_num): Templatize base type of __member argument.
        (_M_extract_name): Change type of __member argument to __tm_small_int&.

Index: include/bits/locale_facets_nonio.h
===================================================================
--- include/bits/locale_facets_nonio.h  (revision 216243)
+++ include/bits/locale_facets_nonio.h  (working copy)
@@ -42,6 +42,15 @@ namespace std _GLIBCXX_VISIBILITY(defaul
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

+#ifdef __AVR__
+/* The struct tm defined in avr-libc/include/time.h uses int8_t for a number
+   of fields.  To allow overload resolution to succeed, we need to adjust
+   some data structures and functions to match.  */
+typedef typeof (((tm*)0)->tm_sec) __tm_small_int;

I think this should probably use __typeof__ to work with
-Wpedantic-errors

+#else /* For 100% mangling compatibility, use int directly.  */
+#define __tm_small_int int
+#endif

I'd prefer to always use a typedef, which can be a private member of
std::time_get, instead of defining a macro (even a macro using a
reserved name).

  /**
   *  @brief  Time format ordering data.
   *  @ingroup locales
@@ -654,14 +663,16 @@ namespace std _GLIBCXX_VISIBILITY(defaul
                  ios_base::iostate& __err, tm* __tm) const;

      // Extract numeric component of length __len.
+      template <typename _Member_t>
      iter_type
-      _M_extract_num(iter_type __beg, iter_type __end, int& __member,
+      _M_extract_num(iter_type __beg, iter_type __end, _Member_t& __member,
                     int __min, int __max, size_t __len,
                     ios_base& __io, ios_base::iostate& __err) const;

I think this function is exported from the library, so turning it into
a template would be an ABI change.

      // Extract any unique array of string literals in a const _CharT* array.
      iter_type
-      _M_extract_name(iter_type __beg, iter_type __end, int& __member,
+      _M_extract_name(iter_type __beg, iter_type __end,
+                     __tm_small_int& __member,
                      const _CharT** __names, size_t __indexlen,
                      ios_base& __io, ios_base::iostate& __err) const;

This part should be OK, since it only affects AVR.

Reply via email to