<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++ creates symbol it cannot demangle."
   href="https://bugs.llvm.org/show_bug.cgi?id=35646">35646</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang++ creates symbol it cannot demangle.
          </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>huangs@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following program, saved as "a.cc"

**** a.cc ****
#include <string>

std::string get_value() {
  return "sparrow";
}

int main() {
  static const std::string& weird = get_value();
  return 0;
}
========

Build, get symbol for |weird| and demangle:

  clang++ a.cc
  llvm-nm a.out | grep weird     # Output 1
  llvm-nm a.out --demangle | grep weird    # Output 2

Results:

**** Output 1 ****
00000000006010a0 b _ZGRZ4mainE5weird_
0000000000601098 b _ZGVZ4mainE5weird
0000000000601090 b _ZZ4mainE5weird
========

**** Output 2 ****
00000000006010a0 b _ZGRZ4mainE5weird_
0000000000601098 b guard variable for main::weird
0000000000601090 b main::weird
========

So "_ZGRZ4mainE5weird_" cannot be demangled (llvm-cxxfilt does not work
either).  Interestingly, c++filt can demangle it as:

  reference temporary #0 for main::weird

So it seems one of the following is broken:

(1) Mangled name generation producing an invalid value.
(2) Demangling not properly working (perhaps with extension).</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>