<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 - Operator overload resolution fails in fold expressions"
   href="https://bugs.llvm.org/show_bug.cgi?id=46577">46577</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Operator overload resolution fails in fold expressions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>C++17
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>micjabbour@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given the following minimal example (which compiles successfully on GCC and
MSVC):


struct A {};

namespace detail {
// operator+ overload
A operator+(A, A) { return A{}; }
A f(A a) {
  return a + a; // this works fine
}
template <typename... As> A g(As... as) {
  // this however, fails to find operator+ when g is instantiated with "A"s
  return (as + ... + A{});
}
}

int main() {
  detail::f(A{}); // works
  detail::g(A{}); // fails!
}


Clang gives the following error:

D:\ws> clang++ -std=c++17 prog.cc
prog.cc:11:16: error: call to function 'operator+' that is neither visible in
the template definition nor found by argument-dependent lookup
  return (as + ... + A{});
               ^
prog.cc:17:11: note: in instantiation of function template specialization
'detail::g<A>' requested here
  detail::g(A{}); // fails!
          ^
prog.cc:5:3: note: 'operator+' should be declared prior to the call site or in
the global namespace
A operator+(A, A) { return A{}; }
  ^
1 error generated.</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>