Skip to content

Error building ./src/coreclr/src/inc/slist.h with clang 10 #32875

@omajid

Description

@omajid

I am trying to build coreclr using clang 10 (rc2), on Fedora 33.

/home/omajid/coreclr/src/inc/slist.h:163:17: error: no viable overloaded '='
        m_pHead = &m_link;
        ~~~~~~~ ^ ~~~~~~~
/home/omajid/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument
class __DPtr : public __DPtrBase<type,__DPtr<type> >
      ^
In file included from /home/omajid/coreclr/src/vm/appdomain.cpp:6:
In file included from /home/omajid/coreclr/src/vm/common.h:311:
/home/omajid/coreclr/src/inc/slist.h:169:21: error: no viable overloaded '='
            m_pTail = &m_link;
            ~~~~~~~ ^ ~~~~~~~
/home/omajid/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument
class __DPtr : public __DPtrBase<type,__DPtr<type> >
      ^
In file included from /home/omajid/coreclr/src/vm/appdomain.cpp:6:
In file included from /home/omajid/coreclr/src/vm/common.h:311:
/home/omajid/coreclr/src/inc/slist.h:277:21: error: no viable overloaded '='
            m_pTail = prior;
            ~~~~~~~ ^ ~~~~~
/home/omajid/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument
class __DPtr : public __DPtrBase<type,__DPtr<type> >
      ^
3 errors generated.

@tmds suggested the code doesn't look valid at all and he wasn't sure how this was even being compiled at all on clang 9 (or earlier).

If I delete those #ifndef ... lines, older versions of clang also complain the code is invalid:

 In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/unwinder/unwinder.cpp:7:                    
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/unwinder/stdafx.h:14:                       
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/common.h:309:                              /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/slist.h:190:30: error: no viable overloaded '='               
              m_pTail->m_pNext = pLink;                                                                               
              ~~~~~~~~~~~~~~~~ ^ ~~~~~                                                                                
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy 
assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument         
  class __DPtr : public __DPtrBase<type,__DPtr<type> >                                                                
        ^                                                                                                             
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/debug/ee/controller.cpp:20:
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/debug/ee/stdafx.h:29:
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/debug/ee/debugger.h:32:
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/common.h:309:
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/slist.h:163:17: error: no viable overloaded '='
          m_pHead = &m_link;
          ~~~~~~~ ^ ~~~~~~~
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/slist.h:156:9: note: in instantiation of member function 'SLis
t<LoaderAllocator::FailedTypeInitCleanupListItem, false, LoaderAllocator::FailedTypeInitCleanupListItem *, &LoaderAllo
cator::FailedTypeInitCleanupListItem::m_Link>::Init' requested here
          Init();
          ^
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/loaderallocator.hpp:145:28: note: in instantiation of member fu
nction 'SList<LoaderAllocator::FailedTypeInitCleanupListItem, false, LoaderAllocator::FailedTypeInitCleanupListItem *,
 &LoaderAllocator::FailedTypeInitCleanupListItem::m_Link>::SList' requested here
      VPTR_BASE_VTABLE_CLASS(LoaderAllocator)
                             ^
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy 
assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument
  class __DPtr : public __DPtrBase<type,__DPtr<type> >
        ^
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/array.cpp:11:                            
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/common.h:309:                            
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/slist.h:190:30: error: no viable overloaded '='               
              m_pTail->m_pNext = pLink;                                                                               
              ~~~~~~~~~~~~~~~~ ^ ~~~~~                                                                                
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy 
assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument         
  class __DPtr : public __DPtrBase<type,__DPtr<type> >                                                                
        ^                                                                                                             
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/array.cpp:11:                            
  In file included from /home/omajid/devel/dotnet/runtime/src/coreclr/src/vm/common.h:309:                            
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/slist.h:209:30: error: no viable overloaded '='               
              m_pHead->m_pNext = pLink;                                                                               
              ~~~~~~~~~~~~~~~~ ^ ~~~~~                                                                                
  /home/omajid/devel/dotnet/runtime/src/coreclr/src/inc/daccess.h:1149:7: note: candidate function (the implicit copy 
assignment operator) not viable: no known conversion from 'SLink *' to 'const __DPtr<SLink>' for 1st argument         
  class __DPtr : public __DPtrBase<type,__DPtr<type> >                                                                
        ^                                                                                                             

It looks like clang 10 analyzes code in functions never called: call site is guarded by #ifdef, but the definition is not in an #ifdef. Clang 10 now complains about this apparently invalid code.

I can get the build to work successfully locally using this, but I don't know if it's the correct fix.

@@ -160,13 +160,13 @@ public:
     void Init()
     {
         LIMITED_METHOD_CONTRACT;
-        m_pHead = &m_link;
+        m_pHead = PTR_SLink(&m_link);
         // NOTE :: fHead variable is template argument 
         // the following code is a compiled in, only if the fHead flag
         // is set to false,
         if (!fHead)
         {
-            m_pTail = &m_link;
+            m_pTail = PTR_SLink(&m_link);
         }
     }
 
@@ -274,7 +274,7 @@ public:
         SLink   *ret = SLink::FindAndRemove(m_pHead, GetLink(pObj), &prior);
         
         if (ret == m_pTail)
-            m_pTail = prior;
+            m_pTail = PTR_SLink(prior);
         
         return GetObject(ret);
     }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions