<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 --- - Itanium ABI: incorrect mangling of unresolved operator name"
   href="http://llvm.org/bugs/show_bug.cgi?id=22584">22584</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Itanium ABI: incorrect mangling of unresolved operator name
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Wolfgang_Pieb@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given the following case:

  struct S4 {
      S4 operator-(S4 rhs) { return rhs; }
  };
  template<class T> auto kkk(T p)->decltype(&T::operator-){}
  template<> decltype(&S4::operator-) kkk(S4 x) { return nullptr; }

clang (r229188) mangles the explicit instantiation of kkk() as:
_Z3kkkI2S4EDTadsrT_miES1_

when the correct mangling should be:

_Z3kkkI2S4EDTadsrT_onmiES1_  (note the additional "on")

The crux is here that T::operator- is an unresolved name and the ABI (chapter
5.1.5) gives the following:

  <base-unresolved-name> ::= <simple-id>             # unresolved name
                         ::= on <operator-name>      # unresolved
operator-function-id
                         ::= on <operator-name> <template-args>    # unresolved
operator template-id

and, later, in an example

          template<class T> auto f(T p)->decltype(&T::operator-);
            // The return type in the mangling of the template signature
            // is encoded as "DTadsrT_onmiE".



gcc 4.8.2 is inconsistent. With the above example, it matches clang's
mangling, but with the following example

  struct S4 {
      S4(int a) {}
  };
  S4 operator+(S4 lhs, S4 rhs) { return rhs; }
  template <class T> auto g(T p1) -> decltype(operator+(p1,p1));
  template <> auto g<S4>(S4 p1) -> decltype(operator+(p1,p1)) { return 0; }

gcc mangles the instantiation of g() correctly to:
_Z1gI2S4EDTclonplfp_fp_EET_

whereas clang leaves out the "on"
_Z1gI2S4EDTclplfp_fp_EET_</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>