[LLVMbugs] [Bug 12085] New: vector::emplace_back requires type to be assignable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Feb 26 00:59:51 PST 2012


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

             Bug #: 12085
           Summary: vector::emplace_back requires type to be assignable
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following program fails to compile with clang r151477 and libc++ r151477:

#include <vector>

struct NonAssignable {
    NonAssignable();
    NonAssignable(NonAssignable&&);
};

int main(int, char**)
{
    std::vector<NonAssignable>  v;
    v.emplace_back();
}


This results in:

$ $ ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++0x -stdlib=libc++
clang.cpp 
In file included from clang.cpp:1:
In file included from /usr/include/c++/v1/vector:261:
In file included from /usr/include/c++/v1/__bit_reference:15:
/usr/include/c++/v1/algorithm:1630:19: error: overload resolution selected
implicitly-deleted copy
      assignment operator
        *__result = _VSTD::move(*__first);
                  ^
/usr/include/c++/v1/algorithm:1654:12: note: in instantiation of function
template specialization
      'std::__1::__move<NonAssignable *, NonAssignable *>' requested here
    return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last),
__unwrap_iter(__result));
           ^
/usr/include/c++/v1/__config:251:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/usr/include/c++/v1/__split_buffer:617:22: note: in instantiation of function
template
      specialization 'std::__1::move<NonAssignable *, NonAssignable *>'
requested here
            __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
                     ^
/usr/include/c++/v1/__config:251:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/usr/include/c++/v1/vector:1510:13: note: in instantiation of function template
specialization
      'std::__1::__split_buffer<NonAssignable,
std::__1::allocator<NonAssignable>
      &>::emplace_back<>' requested here
        __v.emplace_back(_VSTD::forward<_Args>(__args)...);
            ^
clang.cpp:11:7: note: in instantiation of function template specialization
      'std::__1::vector<NonAssignable, std::__1::allocator<NonAssignable>
>::emplace_back<>'
      requested here
    v.emplace_back();
      ^
clang.cpp:3:8: note: candidate function (the implicit copy assignment operator)
has been explicitly
      deleted
struct NonAssignable {
       ^
1 error generated.


The assignment operator has indeed been implicitly deleted; however according
to FDIS 23.2.3 table 101, emplace_back only requires the type to be
EmplaceConstructible and MoveInsertable, both of which is true. It does not
require the type to be MoveAssignable or CopyAssignable.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list