gcc: add llvm-gcc and llvm from trunk (does not successfully compile a target yet...
[openwrt-10.03/.git] / toolchain / gcc / patches / llvm / 307-locale_facets.patch
1 This patch fixes a bug into ostream::operator<<(double) due to the wrong size
2 passed into the __convert_from_v method. The wrong size is then passed to
3 std::snprintf function, that, on uClibc, doens't handle sized 0 buffer.
4
5 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
6
7 --- a/libstdc++-v3/include/bits/locale_facets.tcc
8 +++ b/libstdc++-v3/include/bits/locale_facets.tcc
9 @@ -1149,7 +1149,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
10         const int __cs_size = __fixed ? __max_exp + __prec + 4
11                                       : __max_digits * 2 + __prec;
12         char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
13 -       __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf, 
14 +       __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf, 
15                                       __prec, __v);
16  #endif
17  
18 @@ -1789,7 +1789,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
19        // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
20        const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;
21        char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
22 -      int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", 
23 +      int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, "%.*Lf", 
24                                         0, __units);
25  #endif
26        string_type __digits(__len, char_type());