Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion `!T->isDependentType() && "should not see dependent types here"' failed. #29511

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR30538
Status NEW
Importance P normal
Reported by Chad Rosier (mcrosier@codeaurora.org)
Reported on 2016-09-27 09:05:08 -0700
Last modified on 2016-09-27 17:31:01 -0700
Version unspecified
Hardware PC Windows NT
CC dgregor@apple.com, gberry@codeaurora.org, llvm-bugs@lists.llvm.org, mcrosier@codeaurora.org, rnk@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
CReduced test case:

template <class, unsigned, unsigned> class BF32;
template <template <class, unsigned M, unsigned = M> class BF>
class CRBase {
  enum { BIT };
  BF<bool, BIT> Bit;
};
CRBase<BF32> CR;

Compile with: clang -O3 test.cpp

Should result in the below assertion failure.  However, gcc will report an
error and exit gracefully.

Clang assertion and back trace:

TemplateSpecializationType 0x6a5f1c0 'BF32<_Bool, BIT, BIT>' dependent BF32
|-TemplateArgument type '_Bool'
|-TemplateArgument expr
| `-ImplicitCastExpr 0x6a5f0a8 'unsigned int' <IntegralCast>
|   `-DeclRefExpr 0x6a5f080 'enum CRBase<BF32>::(anonymous at test.cpp:4:3)'
EnumConstant 0x6a5f010 'BIT' 'enum CRBase<BF32>::(anonymous at test.cpp:4:3)'
`-TemplateArgument expr
  `-SubstNonTypeTemplateParmExpr 0x6a37678 'enum CRBase::(anonymous at test.cpp:4:3)'
    `-DeclRefExpr 0x6a37650 'enum CRBase::(anonymous at test.cpp:4:3)' EnumConstant 0x6a375f0 'BIT' 'enum CRBase::(anonymous at test.cpp:4:3)'
clang-3.9: /local/mnt/workspace/mrosier/llvm-
community/llvm/tools/clang/include/clang/AST/TypeNodes.def:98: clang::TypeInfo
clang::ASTContext::getTypeInfoImpl(const clang::Type *) const: Assertion `!T-
>isDependentType() && "should not see dependent types here"' failed.
#0 0x0000000001a1e908 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1a1e908)
#1 0x0000000001a1f4e6 SignalHandler(int) (/local/mnt/workspace/mrosier/llvm-
community/install/bin/clang-3.9+0x1a1f4e6)
#2 0x00007fd81d89dcb0 __restore_rt (/lib/x86_64-linux-
gnu/libpthread.so.0+0xfcb0)
#3 0x00007fd81c427035 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36035)
#4 0x00007fd81c42a79b abort (/lib/x86_64-linux-gnu/libc.so.6+0x3979b)
#5 0x00007fd81c41fe1e (/lib/x86_64-linux-gnu/libc.so.6+0x2ee1e)
#6 0x00007fd81c41fec2 (/lib/x86_64-linux-gnu/libc.so.6+0x2eec2)
#7 0x000000000309aced clang::ASTContext::getTypeInfoImpl(clang::Type const*)
const (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x309aced)
#8 0x0000000003099e7b clang::ASTContext::getTypeInfo(clang::Type const*) const
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x3099e7b)
#9 0x0000000003099c1c clang::ASTContext::getTypeInfoInChars(clang::Type const*)
const (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x3099c1c)
#10 0x000000000324c5f9 (anonymous
namespace)::ItaniumRecordLayoutBuilder::LayoutField(clang::FieldDecl const*,
bool) (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x324c5f9)
#11 0x000000000324f410 (anonymous
namespace)::ItaniumRecordLayoutBuilder::LayoutFields(clang::RecordDecl const*)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x324f410)
#12 0x00000000032455b0 clang::ASTContext::getASTRecordLayout(clang::RecordDecl
const*) const (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x32455b0)
#13 0x0000000001bc0769
clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*,
llvm::StructType*) (/local/mnt/workspace/mrosier/llvm-
community/install/bin/clang-3.9+0x1bc0769)
#14 0x0000000001c63833
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1c63833)
#15 0x0000000001c6469c
clang::CodeGen::CodeGenTypes::getCGRecordLayout(clang::RecordDecl const*)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1c6469c)
#16 0x0000000001c64854
clang::CodeGen::CodeGenTypes::isZeroInitializable(clang::QualType)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1c64854)
#17 0x0000000001bb4a63
clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1bb4a63)
#18 0x0000000001c17529
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x1c17529)
#19 0x0000000001c123fb
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/local/mnt/workspace/mrosier/llvm-
community/install/bin/clang-3.9+0x1c123fb)
#20 0x0000000001c18dc1
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1c18dc1)
#21 0x0000000002242c20 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x2242c20)
#22 0x0000000002241d7c
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x2241d7c)
#23 0x00000000026a1254 clang::ParseAST(clang::Sema&, bool, bool)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x26a1254)
#24 0x0000000001f24f25 clang::FrontendAction::Execute()
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1f24f25)
#25 0x0000000001eed7b1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1eed7b1)
#26 0x0000000001fa921a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-3.9+0x1fa921a)
#27 0x00000000007cd4a1 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/local/mnt/workspace/mrosier/llvm-community/install/bin/clang-
3.9+0x7cd4a1)
#28 0x00000000007cc02b main (/local/mnt/workspace/mrosier/llvm-
community/install/bin/clang-3.9+0x7cc02b)
#29 0x00007fd81c4127ed __libc_start_main (/lib/x86_64-linux-
gnu/libc.so.6+0x217ed)

GCC error:
test.cpp: In instantiation of ‘class CRBase<BF32>’:
test.cpp:7:14:   required from here
test.cpp:5:17: error: ‘CRBase<BF>::Bit’ has incomplete type
   BF<bool, BIT> Bit;
                 ^~~
test.cpp:1:44: note: declaration of ‘class BF32<bool, 0u, 0u>’
 template <class, unsigned, unsigned> class BF32;
                                            ^~~~
Quuxplusone commented 8 years ago
Slightly different test case that passes with GCC without error and crashes
clang:

template <class, unsigned, unsigned> class BF32 {};
template <template <class, unsigned M, unsigned = M> class BF>
class CRBase {
  enum { BIT };
  BF<bool, BIT> Bit;
};
CRBase<BF32> CR;

The difference is that BF32 is declared with an empty class to avoid the GCC
error.  The problem appears to be related to the default parameter and the use
of an enum.  If I pull the enum outside of the CRBase class clang compiles this
code without asserting.

enum { BIT };
template <class, unsigned, unsigned> class BF32 {};
template <template <class, unsigned M, unsigned = M> class BF>
class CRBase {

  BF<bool, BIT> Bit;
};
CRBase<BF32> CR;