Skip to content

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

Closed

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);
     }

Activity

  1. added
    untriaged
    on Feb 26, 2020
  2. omajid commented on Feb 26, 2020

    @omajid
    MemberAuthor

    cc @leecow since this affects our efforts to include .NET Core in Fedora.

  3. leecow commented on Feb 26, 2020

    @leecow
    Member

    cc'ing a few folks that may be able to help: @janvorli, @jashook

  4. tmds commented on Feb 26, 2020

    @tmds
    Member
    m_pHead = &m_link;

    There is no assignment operator form SLink* to __DPtr<SLink>.
    Probably earlier versions of clang didn't give an error, because this method isn't used.
    clang 10 gives an error for it.

    We can make it compile by using the constructor explicitly:

    m_pHead = PTR_SLink(&m_link);
  5. janvorli commented on Mar 2, 2020

    @janvorli
    Member

    @omajid I believe the fix you've suggested is correct. Can you please create a PR for it?

  6. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Infrastructure-coreclruntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions