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: unassignedclangb...@nondot.org
          Reporter: sei_yic...@outlook.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to