<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Clang incorrect applies conversion when built-in operator is selected by overload resolution"
   href="http://llvm.org/bugs/show_bug.cgi?id=20527">20527</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang incorrect applies conversion when built-in operator is selected by overload resolution
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.4
          </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++
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>N3936 13.3.1.2 [over.match.oper]/p7 specifies that 

If a built-in candidate is selected by overload resolution, the operands of
class type are converted to the types of the corresponding parameters of the
selected operation function, except that the second standard conversion
sequence of a user-defined conversion sequence (13.3.3.1.2) is not applied.
Then the operator is treated as the corresponding built-in operator and
interpreted according to Clause 5.

In particular, only operands of class type are converted before the operator is
treated as a built-in and interpreted according to Clause 5, and even then the
second standard conversion sequence (after the user-defined conversion) is not
applied.

The following example is given in the standard:

struct X {
operator double();
};
struct Y {
operator int*();
};
int *a = Y() + 100.0; // error: pointer arithmetic requires integral operand
int *b = Y() + X(); // error: pointer arithmetic requires integral operand

However, clang 3.4 accepts this code, producing no error on either line.
<a href="http://coliru.stacked-crooked.com/a/25bcc0549a19921f">http://coliru.stacked-crooked.com/a/25bcc0549a19921f</a></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>