Patchwork Make vector::at() assertion message more useful (try #2)

login
register
mail settings
Submitter Paul Pluzhnikov
Date Sept. 23, 2013, 4:02 p.m.
Message ID <524065FA.2020301@google.com>
Download mbox | patch
Permalink /patch/277261/
State New
Headers show

Comments

Paul Pluzhnikov - Sept. 23, 2013, 4:02 p.m.
On 9/23/13 7:54 AM, Paolo Carlini wrote:

>> Testing this patch:
> In fact, however, that unsigned long long instantiation isn't
> *unconditionally* available, see locale-inst.cc.

Thanks,

> I think we have to use
> unsigned long as a fall back controlled by the same macro. And please
> add a comment explaining those contortions having to do with the
> available instantiations. Patch pre-approved.

Does this look right?
Paolo Carlini - Sept. 23, 2013, 4:24 p.m.
Hi,

On 9/23/13 11:02 AM, Paul Pluzhnikov wrote:
> On 9/23/13 7:54 AM, Paolo Carlini wrote:
>
>>> Testing this patch:
>> In fact, however, that unsigned long long instantiation isn't
>> *unconditionally* available, see locale-inst.cc.
>
> Thanks,
>
>> I think we have to use
>> unsigned long as a fall back controlled by the same macro. And please
>> add a comment explaining those contortions having to do with the
>> available instantiations. Patch pre-approved.
>
> Does this look right?
Yes. Nit, in the comment I would also explicitly mention locale-inst.cc.

Thanks!
Paolo.

Patch

Index: libstdc++-v3/src/c++11/snprintf_lite.cc
===================================================================
--- libstdc++-v3/src/c++11/snprintf_lite.cc	(revision 202832)
+++ libstdc++-v3/src/c++11/snprintf_lite.cc	(working copy)
@@ -69,11 +69,17 @@ 
    // Returns number of characters appended, or -1 if BUFSIZE is too small.
    int __concat_size_t(char *__buf, size_t __bufsize, size_t __val)
    {
+    // __int_to_char is explicitly instantiated and available only for
+    // some, but not all, types.
+#ifdef _GLIBCXX_USE_LONG_LONG
+    unsigned long long __val2 = __val;
+#else
+    unsigned long __val2 = __val;
+#endif
      // Long enough for decimal representation.
-    unsigned long long __val_ull = __val;
-    int __ilen = 3 * sizeof(__val_ull);
+    int __ilen = 3 * sizeof(__val2);
      char *__cs = static_cast<char*>(__builtin_alloca(__ilen));
-    size_t __len = std::__int_to_char(__cs + __ilen, __val_ull,
+    size_t __len = std::__int_to_char(__cs + __ilen, __val2,
  				      std::__num_base::_S_atoms_out,
  				      std::ios_base::dec, true);
      if (__bufsize < __len)