[llvm-bugs] [Bug 37824] New: Template argument looses 'pointer' when instantiating static

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 17 06:55:58 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37824

            Bug ID: 37824
           Summary: Template argument looses 'pointer' when instantiating
                    static
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jvapen at gmail.com
                CC: llvm-bugs at lists.llvm.org

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:
https://developercommunity.visualstudio.com/content/problem/168272/headers-incompatible-with-llvm-vs2014-toolset-c17.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180617/b7581d62/attachment.html>


More information about the llvm-bugs mailing list