<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 - Template argument looses 'pointer' when instantiating static"
   href="https://bugs.llvm.org/show_bug.cgi?id=37824">37824</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Template argument looses 'pointer' when instantiating static
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jvapen@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Command line:
-------------
cl.exe /EHsc t.cpp /std:c++17
llvm_6_0_0\bin\clang-cl.exe -fms-compatibility-version=19.11 -ferror-limit=2
/EHsc t.cpp /std:c++17 -w 

Full file (t.cpp):
------------------
// This compiles fine without c++17
#include <atlbase.h>
#include <atlwin.h>
int main()
{
    return 0;
}

Reduced file (t.cpp):
---------------------
#include <guiddef.h>

struct __declspec(uuid("B2D0778B-AC99-4c58-A5C8-E7724E5316B5")) A {
  long GetTypeInfo();
};

template <class T, const GUID *piid = &__uuidof(T)> struct B {
  virtual long GetTypeInfo() { return _tih.GetTypeInfo(); }

  static A _tih;
};

template <class T, const GUID *piid> A B<T, piid>::_tih = {};

struct D : public B<A> {
  D() {}
};

error:
------
t.cpp(13,45):  error: value of type 'const _GUID' is not implicitly convertible
to 'const GUID *'
      (aka 'const _GUID *')
template <class T, const GUID *piid> A B<T, piid>::_tih = {};
                                            ^~~~
t.cpp(8,39):  note: in instantiation of static data member 'B<A,
__uuidof(A)>::_tih' requested here
  virtual long GetTypeInfo() { return _tih.GetTypeInfo(); }
                                      ^
t.cpp(16,3):  note: in instantiation of member function 'B<A,
__uuidof(A)>::GetTypeInfo' requested here
  D() {}
  ^

On changing: &__uuidof(T) into &(&__uuidof(T)), one gets the error:
t.cpp(7,39):  error: cannot take the address of an rvalue of type 'const _GUID
*'


This seems to indicate that on class initialization the type is correctly known
by Clang-cl. However, as soon as _tih gets initialized, it looks like the
compiler no longer knows its dealing with a pointer.



Same bug was already reported to microsoft a while ago:
<a href="https://developercommunity.visualstudio.com/content/problem/168272/headers-incompatible-with-llvm-vs2014-toolset-c17.html">https://developercommunity.visualstudio.com/content/problem/168272/headers-incompatible-with-llvm-vs2014-toolset-c17.html</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>