[llvm-bugs] [Bug 43013] New: std::reduce(begin, end, init) does not accept init with only move constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 15 14:47:21 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43013

            Bug ID: 43013
           Summary: std::reduce(begin, end, init) does not accept init
                    with only move constructor
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sei_yichen at outlook.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 22380
  --> https://bugs.llvm.org/attachment.cgi?id=22380&action=edit
repro

Overview: std::reduce(begin, end, init) could not be compiled with init only
have move constructor.



Steps to Reproduce: clang++ -o /dev/null -std=c++17 -c test.cc, test.cc
attched.



Actual Results:
$ clang++ -o /dev/null -std=c++17 -stdlib=libc++ -c test.cc
In file included from test.cc:3:
/home/yiyan/.local/bin/../include/c++/v1/numeric:196:43: error: call to
implicitly-deleted copy constructor of 'T'
    return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());
                                          ^~~~~~
test.cc:17:10: note: in instantiation of function template specialization
'std::__1::reduce<T *, T>' requested here
    std::reduce(t, t + 1, T(0));
         ^
test.cc:9:5: note: copy constructor is implicitly deleted because 'T' has a
user-declared move constructor
    T(T &&); // MoveConstructible
    ^
/home/yiyan/.local/bin/../include/c++/v1/numeric:184:59: note: passing argument
to parameter '__init' here
reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp
__b)
                                                          ^
1 error generated.



Expected Results: Compiled without error.



Build Date & Hardware: Build 2019-08-15 on Linux x86_64



Additional Information: I think std::reduce(begin, end, init) should be same
with std::reduce(begin, end, init, std::plus<>()), the former failed while the
latter passed.

-- 
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/20190815/7450f699/attachment-0001.html>


More information about the llvm-bugs mailing list