[llvm-bugs] [Bug 32642] New: string::insert and append no longer work with move_iterator

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 12 11:13:44 PDT 2017


http://bugs.llvm.org/show_bug.cgi?id=32642

            Bug ID: 32642
           Summary: string::insert and append no longer work with
                    move_iterator
           Product: libc++
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: officesamurai at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Test code:

#include <string>

template <typename Collection>
void insert(Collection& dest, Collection src, size_t pos)
{
    dest.insert(std::next(dest.begin(), pos),
std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
}

int main()
{
    std::string s1, s2;
    insert(s1, std::move(s2), 0);
}

The command line and the result:

~/tmp$ clang++-4.0 test.cpp -std=c++11 -stdlib=libc++ -o test
In file included from test.cpp:1:
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/string:2409:29:
error: cannot take the address of an rvalue of type 'char'
        if ( __ptr_in_range(&*__first, data(), data() + size()))
                            ^~~~~~~~~
test.cpp:6:10: note: in instantiation of function template specialization
'std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char>
>::insert<std::__1::move_iterator<std::__1::__wrap_iter<char *> > >' requested
      here
    dest.insert(std::next(dest.begin(), pos),
std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
         ^
test.cpp:12:5: note: in instantiation of function template specialization
'insert<std::__1::basic_string<char> >' requested here
    insert(s1, std::move(s2), 0);
    ^
1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170412/eed8f8a6/attachment.html>


More information about the llvm-bugs mailing list