<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-cl doesn't output the template parameter on variable templates"
   href="https://bugs.llvm.org/show_bug.cgi?id=39616">39616</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-cl doesn't output the template parameter on variable templates
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>rnk@google.com
          </td>
        </tr>

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

        <tr>
          <th>CC</th>
          <td>aleksandr.urakov@jetbrains.com, jdevlieghere@apple.com, llvm-bugs@lists.llvm.org, mosescu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>template<typename T>
constexpr T Pi = T(3.1415926);


template<typename T>
extern void unresolved(const T *);

int main(int argc, char **argv) {
  unresolved(&Pi<int>);
  unresolved(&Pi<double>);
  unresolved(&Pi<long double>);
  return (int)(Pi<int> + Pi<double> + Pi<long double>);
}

compile and link with both MSVC and clang:

MSVC:
  1) cl.exe /Z7 /GS- /GR- /Fovariable-cl.obj /c variable.cpp
  2) link.exe /debug:full /incremental:no /nodefaultlib /force:unresolved
/entry:main variable-cl.obj

Clang:
  1) clang-cl.exe /Z7 /GS- /GR- -Xclang -fkeep-static-consts /c variable.cpp
  2) lld-link.exe /debug:full /incremental:no /nodefaultlib /force:unresolved
/entry:main variable.obj

Then dump the globals from each and compare:

$ bin\llvm-pdbutil.exe dump -globals variable.pdb


                       Global Symbols
============================================================
  Records
      20 | S_PROCREF [size = 20] `main`
           module = 1, sum name = 0, offset = 52
      40 | S_LDATA32 [size = 20] `Pi`
           type = 0x1003 (const int), addr = 0002:0000
      60 | S_LDATA32 [size = 20] `Pi`
           type = 0x1004 (const double), addr = 0002:0008
      80 | S_LDATA32 [size = 20] `Pi`
           type = 0x1004 (const double), addr = 0002:0016


$ bin\llvm-pdbutil.exe dump -globals variable-cl.pdb

                       Global Symbols
============================================================
  Records
      20 | S_PROCREF [size = 20] `main`
           module = 1, sum name = 0, offset = 176
      40 | S_LDATA32 [size = 24] `Pi<int>`
           type = 0x1051 (const int), addr = 0002:0000
      64 | S_LDATA32 [size = 28] `Pi<double>`
           type = 0x1052 (const double), addr = 0002:0008
      92 | S_LDATA32 [size = 32] `Pi<long double>`
           type = 0x1052 (const double), addr = 0002:0016

As you can see, MSVC puts the template parameter type into the name, whereas we
do not.

The result of this is that in LLDB we can't view variable templates because we
can't look them up (there is actually another bug preventing this as well on
the LLDB side, but fixing this is step 1).</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>