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

login
register
mail settings
Submitter Paul Pluzhnikov
Date Sept. 23, 2013, 2:48 p.m.
Message ID <524054C8.3010502@google.com>
Download mbox | patch
Permalink /patch/277248/
State New
Headers show

Comments

Paul Pluzhnikov - Sept. 23, 2013, 2:48 p.m.
On 9/23/13 4:26 AM, Paolo Carlini wrote:

>> m68k-linux/./libstdc++-v3/src/.libs/libstdc++.so: undefined reference
>> to `int std::__int_to_char<char, unsigned int>(char*, unsigned int,
>> char const*, std::_Ios_Fmtflags, bool)'

Reproduced on i686.
Sorry about the trouble ...

>I would say, either make sure to use only those two in the new
> code

Testing this patch:
Paolo Carlini - Sept. 23, 2013, 2:54 p.m.
Hi,

On 9/23/13 9:48 AM, Paul Pluzhnikov wrote:
> On 9/23/13 4:26 AM, Paolo Carlini wrote:
>
>>> m68k-linux/./libstdc++-v3/src/.libs/libstdc++.so: undefined reference
>>> to `int std::__int_to_char<char, unsigned int>(char*, unsigned int,
>>> char const*, std::_Ios_Fmtflags, bool)'
>
> Reproduced on i686.
> Sorry about the trouble ...
>
>> I would say, either make sure to use only those two in the new
>> code
>
> Testing this patch:
In fact, however, that unsigned long long instantiation isn't 
*unconditionally* available, see locale-inst.cc. 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.

Thanks again,
Paolo.

Patch

Index: libstdc++-v3/src/c++11/snprintf_lite.cc
===================================================================
--- libstdc++-v3/src/c++11/snprintf_lite.cc	(revision 202830)
+++ libstdc++-v3/src/c++11/snprintf_lite.cc	(working copy)
@@ -70,9 +70,10 @@ 
    int __concat_size_t(char *__buf, size_t __bufsize, size_t __val)
    {
      // Long enough for decimal representation.
-    int __ilen = 3 * sizeof(__val);
+    unsigned long long __val_ull = __val;
+    int __ilen = 3 * sizeof(__val_ull);
      char *__cs = static_cast<char*>(__builtin_alloca(__ilen));
-    size_t __len = std::__int_to_char(__cs + __ilen, __val,
+    size_t __len = std::__int_to_char(__cs + __ilen, __val_ull,
  				      std::__num_base::_S_atoms_out,
  				      std::ios_base::dec, true);
      if (__bufsize < __len)