<div dir="ltr">I agree with Nico. Adding _LIBCPP_INLINE_VISIBILITY should fix the problem, but it's a bit of a hack. Also we should only *add* additional signatures if possible since existing signatures already exist in the dylib so we can't modify them.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 11, 2016 at 8:32 AM, Nico Weber via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I reverted this in 263246 for now. I think the right fix is just to add _LIBCPP_INLINE_VISIBILITY to the new constructor, but I'm not 100% sure.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 10, 2016 at 10:21 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think this is ABI-breaking. On OS X, new libc++ headers must work with old system libc++.dylibs. When I build in this setup with this change, I get<div><br></div><div><div>Undefined symbols for architecture x86_64:</div><div>  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, std::__1::allocator<char> const&)", referenced from:</div><div>      </div></div><div>The new function probably needs that always_inline treatment that many other functions have?</div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 12:51 PM, Marshall Clow via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: marshall<br>
Date: Wed Mar  9 11:51:43 2016<br>
New Revision: 263036<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=263036&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=263036&view=rev</a><br>
Log:<br>
Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)<br>
<br>
Modified:<br>
    libcxx/trunk/include/string<br>
    libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp<br>
    libcxx/trunk/www/cxx1z_status.html<br>
<br>
Modified: libcxx/trunk/include/string<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=263036&r1=263035&r2=263036&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/string (original)<br>
+++ libcxx/trunk/include/string Wed Mar  9 11:51:43 2016<br>
@@ -98,8 +98,10 @@ public:<br>
     basic_string(const basic_string& str);<br>
     basic_string(basic_string&& str)<br>
         noexcept(is_nothrow_move_constructible<allocator_type>::value);<br>
-    basic_string(const basic_string& str, size_type pos, size_type n = npos,<br>
+    basic_string(const basic_string& str, size_type pos,                 // LWG#2583<br>
                  const allocator_type& a = allocator_type());<br>
+    basic_string(const basic_string& str, size_type pos, size_type n,    // LWG#2583<br>
+                 const Allocator& a = Allocator());<br>
     basic_string(const value_type* s, const allocator_type& a = allocator_type());<br>
     basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());<br>
     basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());<br>
@@ -1397,7 +1399,9 @@ public:<br>
     basic_string(size_type __n, value_type __c);<br>
     _LIBCPP_INLINE_VISIBILITY<br>
     basic_string(size_type __n, value_type __c, const allocator_type& __a);<br>
-    basic_string(const basic_string& __str, size_type __pos, size_type __n = npos,<br>
+    basic_string(const basic_string& __str, size_type __pos, size_type __n,<br>
+                 const allocator_type& __a = allocator_type());<br>
+    basic_string(const basic_string& __str, size_type __pos,<br>
                  const allocator_type& __a = allocator_type());<br>
     template<class _InputIterator><br>
         _LIBCPP_INLINE_VISIBILITY<br>
@@ -2220,6 +2224,20 @@ basic_string<_CharT, _Traits, _Allocator<br>
 #if _LIBCPP_DEBUG_LEVEL >= 2<br>
     __get_db()->__insert_c(this);<br>
 #endif<br>
+}<br>
+<br>
+template <class _CharT, class _Traits, class _Allocator><br>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,<br>
+                                                        const allocator_type& __a)<br>
+    : __r_(__a)<br>
+{<br>
+    size_type __str_sz = __str.size();<br>
+    if (__pos > __str_sz)<br>
+        this->__throw_out_of_range();<br>
+    __init(__str.data() + __pos, __str_sz - __pos);<br>
+#if _LIBCPP_DEBUG_LEVEL >= 2<br>
+    __get_db()->__insert_c(this);<br>
+#endif<br>
 }<br>
<br>
 template <class _CharT, class _Traits, class _Allocator><br>
<br>
Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263036&r1=263035&r2=263036&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=263036&r1=263035&r2=263036&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp (original)<br>
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp Wed Mar  9 11:51:43 2016<br>
@@ -11,14 +11,21 @@<br>
 // <string><br>
<br>
 // basic_string(const basic_string<charT,traits,Allocator>& str,<br>
-//              size_type pos, size_type n = npos,<br>
+//              size_type pos, size_type n,<br>
+//              const Allocator& a = Allocator());<br>
+//<br>
+// basic_string(const basic_string<charT,traits,Allocator>& str,<br>
+//              size_type pos,<br>
 //              const Allocator& a = Allocator());<br>
<br>
 #include <string><br>
 #include <stdexcept><br>
 #include <algorithm><br>
+#include <vector><br>
+#include <scoped_allocator><br>
 #include <cassert><br>
<br>
+#include "test_macros.h"<br>
 #include "test_allocator.h"<br>
 #include "min_allocator.h"<br>
<br>
@@ -91,6 +98,20 @@ test(S str, unsigned pos, unsigned n, co<br>
     }<br>
 }<br>
<br>
+#if TEST_STD_VER >= 11<br>
+void test2583()<br>
+{   // LWG #2583<br>
+    typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > StringA;<br>
+    std::vector<StringA, std::scoped_allocator_adaptor<test_allocator<StringA>>> vs;<br>
+    StringA s{"1234"};<br>
+    vs.emplace_back(s, 2);<br>
+<br>
+    try { vs.emplace_back(s, 5); }<br>
+    catch (const std::out_of_range&) { return; }<br>
+    assert(false);<br>
+}<br>
+#endif<br>
+<br>
 int main()<br>
 {<br>
     {<br>
@@ -131,7 +152,7 @@ int main()<br>
     test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));<br>
     test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));<br>
     }<br>
-#if __cplusplus >= 201103L<br>
+#if TEST_STD_VER >= 11<br>
     {<br>
     typedef min_allocator<char> A;<br>
     typedef std::basic_string<char, std::char_traits<char>, A> S;<br>
@@ -170,5 +191,7 @@ int main()<br>
     test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());<br>
     test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());<br>
     }<br>
+<br>
+    test2583();<br>
 #endif<br>
 }<br>
<br>
Modified: libcxx/trunk/www/cxx1z_status.html<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=263036&r1=263035&r2=263036&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=263036&r1=263035&r2=263036&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/www/cxx1z_status.html (original)<br>
+++ libcxx/trunk/www/cxx1z_status.html Wed Mar  9 11:51:43 2016<br>
@@ -227,7 +227,7 @@<br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2579" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2579</a>">2579</a></td><td>Inconsistency wrt Allocators in <tt>basic_string</tt> assignment vs. <tt>basic_string::assign</tt></td><td>Jacksonville</td><td><i></i></td></tr><br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2581" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2581</a>">2581</a></td><td>Specialization of <tt>&lt;type_traits&gt;</tt> variable templates should be prohibited</td><td>Jacksonville</td><td>Complete</td></tr><br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2582" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2582</a>">2582</a></td><td>&sect;[res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traits</td><td>Jacksonville</td><td></td></tr><br>
-       <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2583" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2583</a>">2583</a></td><td>There is no way to supply an allocator for <tt>basic_string(str, pos)</tt></td><td>Jacksonville</td><td><i></i></td></tr><br>
+       <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2583" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2583</a>">2583</a></td><td>There is no way to supply an allocator for <tt>basic_string(str, pos)</tt></td><td>Jacksonville</td><td>Complete</td></tr><br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2585" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2585</a>">2585</a></td><td><tt>forward_list::resize(size_type, const value_type&amp;)</tt> effects incorrect</td><td>Jacksonville</td><td></td></tr><br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2586" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2586</a>">2586</a></td><td>Wrong value category used in <tt>scoped_allocator_adaptor::construct()</tt></td><td>Jacksonville</td><td></td></tr><br>
        <tr><td><a href="<a href="http://cplusplus.github.io/LWG/lwg-defects.html#2590" rel="noreferrer" target="_blank">http://cplusplus.github.io/LWG/lwg-defects.html#2590</a>">2590</a></td><td>Aggregate initialization for <tt>std::array</tt></td><td>Jacksonville</td><td>Complete</td></tr><br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>