<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - std::reduce(begin, end, init) does not accept init with only move constructor"
   href="https://bugs.llvm.org/show_bug.cgi?id=43013">43013</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::reduce(begin, end, init) does not accept init with only move constructor
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sei_yichen@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22380" name="attach_22380" title="repro">attachment 22380</a> <a href="attachment.cgi?id=22380&action=edit" title="repro">[details]</a></span>
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>