<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 - Lambda call operator invoked if streamed to std::cout"
   href="https://bugs.llvm.org/show_bug.cgi?id=39911">39911</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Lambda call operator invoked if streamed to std::cout
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>golka.gerald@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following code:

int main()
{
    auto lam = [](auto x) {return x*2;};
    std::cout << lam; // fails with: "error: invalid operands to binary
expression ('std::basic_ostream<char>' and 'int')"
}

If a lambda is passed to std::cout compilation does not fail as expected. It
fails but for the wrong reason ("invalid operands to binary expression, rather
than "no matching function call"). It seems that the call operator is
instantiated (and called with iostream as input) somewhere in the overload
resolution. I think that this is not correct. The problem in my use case is,
that this breaks expression sfinae. 

See the more comprehensive example here: <a href="https://godbolt.org/z/-6fz0o">https://godbolt.org/z/-6fz0o</a>

The code works as expected with gcc and msvc, so I guess it's a clang problem.</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>