<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 - Clang does not match GCC re: instantiation-dependent expressions in mangling"
   href="https://bugs.llvm.org/show_bug.cgi?id=52191">52191</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang does not match GCC re: instantiation-dependent expressions in mangling
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>ABI
          </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>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>arthur.j.odwyer@gmail.com, 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>As noted by Arthur O'Dwyer in <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Invalid subexpression in sizeof fails to remove candidate"
   href="show_bug.cgi?id=28667">bug 28667</a>, Clang does not mangle
instantiation-dependent (but neither type nor value dependent) expressions as
GCC does.

For example, given:
struct A { A(int); };

template <typename T> void foo(int, char (*)[sizeof(0, A(T()))]) { }
template <typename T> void foo(int, ...);

int main(void) {
  foo<decltype(nullptr)>(0, 0);
  foo<int>(0, 0);
}

The sizeof expression is instantiation-dependent: substitution with nullptr_t
fails.

Clang mangles the `int` specialization as `_Z3fooIiEviPA1_c` (i.e., `void
foo<int>(int, char (*) [1])`). GCC mangles it as
`_Z3fooIiEviPAszcmLi0Ecv1AcvT__E_c` (i.e., `void foo<int>(int, char (*) [sizeof
((0),((A)((int)())))])`).

Online compiler: <a href="https://gcc.godbolt.org/z/exj1onseW">https://gcc.godbolt.org/z/exj1onseW</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>