<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 - Build failure with _LIBCPP_DEBUG=0 and non-const-ref comparator for std::sort()"
   href="https://bugs.llvm.org/show_bug.cgi?id=41017">41017</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Build failure with _LIBCPP_DEBUG=0 and non-const-ref comparator for std::sort()
          </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>enhancement
          </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>thomasanderson@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>libc++ version is close to ToT:
<a href="https://chromium.googlesource.com/chromium/llvm-project/libcxx/+/9ae8fb4a3c5fef4e9d41e97bbd9397a412932ab0">https://chromium.googlesource.com/chromium/llvm-project/libcxx/+/9ae8fb4a3c5fef4e9d41e97bbd9397a412932ab0</a>

Building the below program with libc++ succeeds, but fails when
-D_LIBCPP_DEBUG=0 is used (build failure: <a href="https://godbolt.org/z/AOroMY">https://godbolt.org/z/AOroMY</a>). 
Changing "int&" to "const int&" gets rid of the error.  The build should either
succeed or fail in both configurations.

#include <algorithm>
#include <vector>
int main() {
    std::vector<int> v;
    std::sort(v.begin(), v.end(), [](int& i1, int& i2) {
        return false;
    });
}</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>