New issue
Advanced search Search tips

Issue 775174 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug

Blocked on:
issue 775171

Blocking:
issue 82385
issue 773476



Sign in to add a comment

clang can't handle wrl/implements.h

Project Member Reported by brucedaw...@chromium.org, Oct 16 2017

Issue description

Opening a bug to formally track this issue...

When compiling Chrome with the Fall Creators Update SDK and with is_clang = true in args.gn the compilation fails with this error:

>ninja -C out\clang obj/third_party/angle/libANGLE/driver_utils.obj
ninja.exe -C out\clang obj/third_party/angle/libANGLE/driver_utils.obj -j 960 -l 48
ninja: Entering directory `out\clang'
[1 processes, 1/1 @ 0.4/s : 2.492s ] CXX obj/third_party/angle/libANGLE/driver_utils.obj
FAILED: obj/third_party/angle/libANGLE/driver_utils.obj
C:\goma\goma-win64/gomacc.exe ../../third_party/llvm-build/Release+Asserts/bin/clang-cl.exe /nologo /showIncludes @obj/third_party/angle/libANGLE/driver_utils.obj.rsp /c ../../third_party/angle/src/libANGLE/renderer/driver_utils.cpp /Foobj/third_party/angle/libANGLE/driver_utils.obj /Fd"obj/third_party/angle/libANGLE_cc.pdb"
In file included from ../../third_party/angle/src/libANGLE/renderer/driver_utils.cpp:11:
In file included from ../../third_party/angle/src\libANGLE/renderer/driver_utils.h:12:
In file included from ../../third_party/angle/src\libANGLE/angletypes.h:12:
In file included from ../../third_party/angle/src\common/bitset_utils.h:17:
In file included from ../../third_party/angle/src\common/angleutils.h:12:
In file included from ../../third_party/angle/src\common/platform.h:71:
In file included from c:\program files (x86)\windows kits\10\include\10.0.16299.0\winrt\wrl.h:16:
c:\program files (x86)\windows kits\10\include\10.0.16299.0\winrt\wrl\implements.h(944,16): error: ambiguous conversion from derived class 'Microsoft::WRL::Details::ImplementsHelper<Microsoft::WRL::RuntimeClassFlags<3>, true, Microsoft::WRL::CloakedIid<IMarshal> >' to base class 'Microsoft::WRL::Details::ImplementsHelper<Microsoft::WRL::RuntimeClassFlags<3>, true>':
struct Microsoft::WRL::Details::ImplementsHelper<struct Microsoft::WRL::RuntimeClassFlags<3>, true, struct Microsoft::WRL::CloakedIid<struct IMarshal> > -> ImplementsHelper<struct Microsoft::WRL::RuntimeClassFlags<3>, true, struct IMarshal> -> ImplementsHelper<struct Microsoft::WRL::RuntimeClassFlags<3>, true>
struct Microsoft::WRL::Details::ImplementsHelper<struct Microsoft::WRL::RuntimeClassFlags<3>, true, struct Microsoft::WRL::CloakedIid<struct IMarshal> > -> ImplementsHelper<struct Microsoft::WRL::RuntimeClassFlags<3>, true>
return ImplementsHelper<RuntimeClassFlagsT, true, TInterfaces...>::CanCastTo(riid, ppv, pRefDelegated);
^~~~~~~~~~~~~~~~
c:\program files (x86)\windows kits\10\include\10.0.16299.0\winrt\wrl\implements.h(1236,95): note: in instantiation of member function 'Microsoft::WRL::Details::ImplementsHelper<Microsoft::WRL::RuntimeClassFlags<3>, true, Microsoft::WRL::CloakedIid<IMarshal> >::CanCastTo' requested here
return Details::ImplementsHelper<RuntimeClassFlags<flags>, true, I0, TInterfaces...>::CanCastTo(riid, ppv);
^
c:\program files (x86)\windows kits\10\include\10.0.16299.0\winrt\wrl\implements.h(1279,23): note: in instantiation of member function 'Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<3>, Microsoft::WRL::CloakedIid<IMarshal> >::CanCastTo' requested here
return Super::CanCastTo(riid, ppv);
^
1 error generated.
ninja: build stopped: subcommand failed.


The clang-cl team came up with this reduction:
struct A { void f(); };
struct B : A {};
struct C : A, B { void f() { A::f(); } };

Clang and GCC reject, MSVC accepts. There are two 'A' base subobjects in C, so it's supposed to be ambiguous. Of course, when all classes are empty, it's kind of academic.

WRL has to silence C4584 in the WRL header, which is supposed to tell you when you've directly inherited from the same base twice:
#pragma warning(disable: 4584) // 'class1' : base-class 'class2' is already a base-class of 'class3'


It is likely that MSVC will not be changed to reject this code and it is likely that WRL will not be changed to stop using this pattern so it appears that clang-cl will have to learn to handle this. This bug is the main bug blocking a switch to the Fall Creators Update SDK. This is not a critical issue at the moment (crrev.com/c/714366 is currently stopping developers from accidentally using the Fall Creators Update SDK) but we are likely to want to move forwards at some point. Fixing this would also make it easier for us to switch to the VS 2017 Update 4 (15.4) toolchain which has some compiler bug fixes.

 

Comment 2 by thakis@chromium.org, Oct 27 2017

#include <stddef.h>

struct A { void f(); double a; };
struct B : A { int b; };
struct B2 : A { int b2; };

struct C : A, B {
  void f() {
    static_assert(offsetof(C, A::a) == 0, "off");
    static_assert(offsetof(C, B::A::a) == 8, "off");
  }
};
static_assert(sizeof(C) == 24, "foo");


struct C2 : B, A {
  void f() {
    static_assert(offsetof(C2, A::a) == 16, "off");
    static_assert(offsetof(C2, B::A::a) == 0, "off");
  }
};
static_assert(sizeof(C2) == 24, "foo");

struct C3 : B, B2 {
  void f() {
    int a = A::a;
    static_assert(offsetof(C3, A::a) == 0, "off");
    static_assert(offsetof(C3, B::A::a) == 0, "off");
    static_assert(offsetof(C3, B2::A::a) == 16, "off");
  }
};
static_assert(sizeof(C3) == 32, "foo");

Comment 3 by thakis@chromium.org, Oct 27 2017

Blocking: 82385
Cc: r...@chromium.org
Components: Build
Labels: clang OS-Windows
Owner: thakis@chromium.org

Comment 5 by thakis@chromium.org, Oct 27 2017

diags here:

(gdb) bt
#0  clang::Sema::CheckDerivedToBaseConversion (this=this@entry=0x4c72c50, Derived=Derived@entry=..., Base=Base@entry=..., Loc=Loc@entry=..., Range=Range@entry=..., 
    BasePath=BasePath@entry=0x7fffffffa7f0, IgnoreAccess=IgnoreAccess@entry=false) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaDeclCXX.cpp:2612
#1  0x0000000002b66ac1 in clang::Sema::PerformObjectMemberConversion (this=this@entry=0x4c72c50, From=From@entry=0x4cb0610, Qualifier=<optimized out>, FoundDecl=FoundDecl@entry=
    0x4c8ed90, Member=Member@entry=0x4c8ed90) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaExpr.cpp:2574
#2  0x0000000002c24e84 in clang::Sema::BuildFieldReferenceExpr (this=this@entry=0x4c72c50, BaseExpr=BaseExpr@entry=0x4cb0610, IsArrow=IsArrow@entry=true, OpLoc=..., 
    OpLoc@entry=..., SS=..., Field=Field@entry=0x4c8ed90, FoundDecl=FoundDecl@entry=..., MemberNameInfo=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaExprMember.cpp:1796
#3  0x0000000002c2a336 in clang::Sema::BuildMemberReferenceExpr (this=this@entry=0x4c72c50, BaseExpr=0x4cb0610, BaseExprType=BaseExprType@entry=..., OpLoc=..., OpLoc@entry=..., 
    IsArrow=IsArrow@entry=true, SS=..., TemplateKWLoc=TemplateKWLoc@entry=..., FirstQualifierInScope=FirstQualifierInScope@entry=0x0, R=..., 
    TemplateArgs=TemplateArgs@entry=0x0, S=S@entry=0x4cacb60, SuppressQualifierCheck=SuppressQualifierCheck@entry=false, ExtraArgs=ExtraArgs@entry=0x0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaExprMember.cpp:1137
#4  0x0000000002c2b085 in clang::Sema::BuildImplicitMemberExpr (this=this@entry=0x4c72c50, SS=..., TemplateKWLoc=TemplateKWLoc@entry=..., R=..., 
    TemplateArgs=TemplateArgs@entry=0x0, IsKnownInstance=<optimized out>, S=0x4cacb60) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaExprMember.cpp:1850
#5  0x0000000002c2b620 in clang::Sema::BuildPossibleImplicitMemberExpr (this=this@entry=0x4c72c50, SS=..., TemplateKWLoc=..., TemplateKWLoc@entry=..., R=..., 
    TemplateArgs=TemplateArgs@entry=0x0, S=S@entry=0x4cacb60) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaExprMember.cpp:249
#6  0x0000000002a94ac9 in clang::Sema::ClassifyName (this=<optimized out>, S=0x4cacb60, SS=..., Name=@0x7fffffffae88: 0x4c9d810, NameLoc=..., NameLoc@entry=..., NextToken=..., 
    IsAddressOfOperand=IsAddressOfOperand@entry=false, CCC=std::unique_ptr<clang::CorrectionCandidateCallback> containing 0x0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Sema/SemaDecl.cpp:1149
#7  0x00000000027c650d in clang::Parser::TryAnnotateName (this=this@entry=0x4c776a0, IsAddressOfOperand=IsAddressOfOperand@entry=false, 
    CCC=std::unique_ptr<clang::CorrectionCandidateCallback> containing 0x0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/Parser.cpp:1498
#8  0x00000000028579f1 in clang::Parser::isCXXDeclarationSpecifier (this=this@entry=0x4c776a0, BracedCastResult=BracedCastResult@entry=clang::Parser::TPResult::False, 
    HasMissingTypename=HasMissingTypename@entry=0x7fffffffb0ef) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseTentative.cpp:1430
#9  0x00000000028576bd in clang::Parser::isCXXDeclarationSpecifier (this=this@entry=0x4c776a0, BracedCastResult=BracedCastResult@entry=clang::Parser::TPResult::False, 
    HasMissingTypename=HasMissingTypename@entry=0x7fffffffb0ef) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseTentative.cpp:1293
#10 0x0000000002858d97 in clang::Parser::isCXXSimpleDeclaration (this=0x4c776a0, AllowForRangeDecl=AllowForRangeDecl@entry=false)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseTentative.cpp:116
#11 0x0000000002858f74 in clang::Parser::isCXXDeclarationStatement (this=this@entry=0x4c776a0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseTentative.cpp:65
#12 0x0000000002842249 in isDeclarationStatement (this=0x4c776a0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/include/clang/Parse/Parser.h:1996
#13 clang::Parser::ParseStatementOrDeclarationAfterAttributes (this=this@entry=0x4c776a0, Stmts=..., Allowed=Allowed@entry=clang::Parser::ACK_Any, 
    TrailingElseLoc=<optimized out>, Attrs=...) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseStmt.cpp:212
#14 0x000000000284236d in clang::Parser::ParseStatementOrDeclaration (this=this@entry=0x4c776a0, Stmts=..., Allowed=Allowed@entry=clang::Parser::ACK_Any, 
    TrailingElseLoc=TrailingElseLoc@entry=0x0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseStmt.cpp:111
#15 0x0000000002846377 in clang::Parser::ParseCompoundStatementBody (this=this@entry=0x4c776a0, isStmtExpr=isStmtExpr@entry=false)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseStmt.cpp:1003
#16 0x0000000002848459 in clang::Parser::ParseFunctionStatementBody (this=this@entry=0x4c776a0, Decl=0x4cb04d8, BodyScope=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseStmt.cpp:1969
#17 0x00000000027cdcc5 in clang::Parser::ParseLexedMethodDef (this=0x4c776a0, LM=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:551
#18 0x00000000027cda8e in clang::Parser::ParseLexedMethodDefs (this=0x4c776a0, Class=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:479
#19 0x00000000027fd121 in clang::Parser::ParseCXXMemberSpecification (this=this@entry=0x4c776a0, RecordLoc=..., AttrFixitLoc=..., AttrFixitLoc@entry=..., Attrs=..., 
    TagType=TagType@entry=19, TagDecl=TagDecl@entry=0x4c8f2f0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseDeclCXX.cpp:3298
#20 0x00000000027ff631 in clang::Parser::ParseClassSpecifier (this=this@entry=0x4c776a0, TagTokKind=TagTokKind@entry=clang::tok::kw_struct, StartLoc=..., DS=..., 
    TemplateInfo=..., AS=AS@entry=clang::AS_none, EnteringContext=EnteringContext@entry=true, DSC=DSC@entry=clang::Parser::DSC_top_level, Attributes=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseDeclCXX.cpp:1912
#21 0x00000000027e0595 in clang::Parser::ParseDeclarationSpecifiers (this=this@entry=0x4c776a0, DS=..., TemplateInfo=..., AS=AS@entry=clang::AS_none, 
---Type <return> to continue, or q <return> to quit---
    DSContext=DSContext@entry=clang::Parser::DSC_top_level, LateAttrs=LateAttrs@entry=0x0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseDecl.cpp:3622
#22 0x00000000027c6ec6 in clang::Parser::ParseDeclOrFunctionDefInternal (this=this@entry=0x4c776a0, attrs=..., DS=..., AS=clang::AS_none)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/Parser.cpp:914
#23 0x00000000027c768e in clang::Parser::ParseDeclarationOrFunctionDefinition (this=this@entry=0x4c776a0, attrs=..., DS=<optimized out>, AS=AS@entry=clang::AS_none)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/Parser.cpp:995
#24 0x00000000027c9dc0 in clang::Parser::ParseExternalDeclaration (this=this@entry=0x4c776a0, attrs=..., DS=DS@entry=0x0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/Parser.cpp:845
#25 0x00000000027cc7d1 in clang::Parser::ParseTopLevelDecl (this=this@entry=0x4c776a0, Result=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/Parser.cpp:613
#26 0x00000000027c4a0b in clang::ParseAST (S=..., PrintStats=<optimized out>, SkipFunctionBodies=<optimized out>)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Parse/ParseAST.cpp:146
#27 0x00000000021bdc77 in clang::ASTFrontendAction::ExecuteAction (this=this@entry=0x4c259e0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Frontend/FrontendAction.cpp:999
#28 0x00000000024a8f64 in clang::CodeGenAction::ExecuteAction (this=0x4c259e0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/CodeGen/CodeGenAction.cpp:1027
#29 0x00000000021bee2e in clang::FrontendAction::Execute (this=this@entry=0x4c259e0) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Frontend/FrontendAction.cpp:897
#30 0x0000000002198b1d in clang::CompilerInstance::ExecuteAction (this=this@entry=0x4c21fc0, Act=...)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/Frontend/CompilerInstance.cpp:990
#31 0x0000000002243fd4 in clang::ExecuteCompilerInvocation (Clang=Clang@entry=0x4c21fc0)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252
#32 0x0000000000ab1c98 in cc1_main (Argv=..., Argv0=<optimized out>, MainAddr=MainAddr@entry=0xaaf2e0 <GetExecutablePath(char const*, bool)>)
    at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/tools/driver/cc1_main.cpp:221
#33 0x0000000000a2ec03 in ExecuteCC1Tool (Tool=..., argv=...) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/tools/driver/driver.cpp:309
#34 main (argc_=<optimized out>, argv_=<optimized out>) at /usr/local/google/home/thakis/src/llvm-rw/tools/clang/tools/driver/driver.cpp:388

Comment 6 by r...@chromium.org, Oct 27 2017

Patch out for review: https://reviews.llvm.org/D39389

Comment 7 by r...@chromium.org, Oct 27 2017

Hm, I guess it doesn't handle all the cases in c#2, but I think that's an incompatibility in our offsetof implementation.

Comment 8 by thakis@chromium.org, Oct 30 2017

Blockedon: 775171
Status: Started (was: Assigned)
r316807

Comment 9 by h...@chromium.org, Nov 7 2017

Status: Fixed (was: Started)
Clang was rolled, so this should be fixed.

Sign in to add a comment