<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 - Demangler produces incorrect output for alignof() and array."
   href="https://bugs.llvm.org/show_bug.cgi?id=35651">35651</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Demangler produces incorrect output for alignof() and array.
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>huangs@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Please run the following:

  llvm-cxxfilt _Z3fooDTatA123_3barE

The result:

  foo(decltype(alignof (bar [123]) [123]))

The extra "[123]" at end seems wrong. Note that replacing "at" with "st" yields
correct result:

  llvm-cxxfilt _Z3fooDTstA123_3barE

=>

  foo(decltype(sizeof (bar [123]))


This behavior is caused by code in 2 places (see ItaniumDemangle.cpp)

(1) In struct string_pair: We have 

    StrT move_full() { return std::move(first) + std::move(second); }

  this actually does not clear |first| and |second|!

(2) Compare parse_sizeof_type_expr() with parse_alignof_type(): The former has

    db.names.back() = "sizeof (" + db.names.back().move_full() + ")

  but the latter has

    db.names.back().first = "alignof (" + db.names.back().move_full() + ")";

  Therefore "st" (sizeof) overwrites |second| whereas "at" (alignof) keeps
stale |second|.</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>