[llvm-bugs] [Bug 27425] New: Assertion failure compiling template aliases with enums
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 19 12:00:57 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27425
Bug ID: 27425
Summary: Assertion failure compiling template aliases with
enums
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: rcraik at ca.ibm.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 16237
--> https://llvm.org/bugs/attachment.cgi?id=16237&action=edit
Patch with fix
With the following testcase:
//t.cpp
template <class T> using A = enum B : T {};
clang hits an assertion failure:
clang -std=c++11 t.cpp
clang-3.9: 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 clang-3.9 0x0000000013436c60 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
+ 68
1 clang-3.9 0x0000000013437050
2 clang-3.9 0x000000001343516c llvm::sys::RunSignalHandlers() + 180
3 clang-3.9 0x0000000013436514
4 0x00003fff87790478 __kernel_sigtramp_rt64 + 0
5 libc.so.6 0x00003fff871e0890 abort + 640
6 libc.so.6 0x00003fff871d4724
7 libc.so.6 0x00003fff871d4814 __assert_fail + 100
8 clang-3.9 0x00000000163ed090 clang::ASTContext::getTypeInfoImpl(clang::Type
const*) const + 880
9 clang-3.9 0x00000000163ecc98 clang::ASTContext::getTypeInfo(clang::Type
const*) const + 192
10 clang-3.9 0x0000000013766850
11 clang-3.9 0x00000000137668b4
12 clang-3.9 0x000000001640ae60 clang::ASTContext::getIntWidth(clang::QualType)
const + 160
13 clang-3.9 0x000000001550a2f0
clang::Sema::ActOnEnumBody(clang::SourceLocation, clang::SourceLocation,
clang::SourceLocation, clang::Decl*, llvm::ArrayRef<clang::Decl*>,
clang::Scope*, clang::AttributeList*) + 1184
14 clang-3.9 0x0000000014ff2ee8
clang::Parser::ParseEnumBody(clang::SourceLocation, clang::Decl*) + 2444
15 clang-3.9 0x0000000014ff241c
clang::Parser::ParseEnumSpecifier(clang::SourceLocation, clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext) + 5408
16 clang-3.9 0x0000000014fefbf0
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 11816
17 clang-3.9 0x0000000014feb4b0
clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&,
clang::AccessSpecifier, clang::Parser::DeclSpecContext) + 112
18 clang-3.9 0x0000000014fdf350
clang::Parser::ParseTypeName(clang::SourceRange*,
clang::Declarator::TheContext, clang::AccessSpecifier, clang::Decl**,
clang::ParsedAttributes*) + 224
19 clang-3.9 0x000000001500be38 clang::Parser::ParseUsingDeclaration(unsigned
int, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation,
clang::SourceLocation&, clang::AccessSpecifier, clang::Decl**) + 2364
20 clang-3.9 0x000000001500b164
clang::Parser::ParseUsingDirectiveOrDeclaration(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, clang::Decl**) + 544
21 clang-3.9 0x000000001508770c
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 448
22 clang-3.9 0x00000000150874e0
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 1112
23 clang-3.9 0x0000000015087048
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 284
24 clang-3.9 0x0000000014fe8a40 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 508
25 clang-3.9 0x0000000014fc4afc
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 3272
26 clang-3.9 0x0000000014fc3dd8
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 812
27 clang-3.9 0x0000000014fbecd8 clang::ParseAST(clang::Sema&, bool, bool) + 464
28 clang-3.9 0x0000000013dd3dd4 clang::ASTFrontendAction::ExecuteAction() + 468
29 clang-3.9 0x000000001430521c clang::CodeGenAction::ExecuteAction() + 1720
30 clang-3.9 0x0000000013dd36a0 clang::FrontendAction::Execute() + 188
31 clang-3.9 0x0000000013d66f2c
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1304
32 clang-3.9 0x0000000013f51904
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1692
33 clang-3.9 0x000000001129adc0 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) + 1156
34 clang-3.9 0x000000001128a68c
35 clang-3.9 0x000000001128b028 main + 1844
36 libc.so.6 0x00003fff871c4580
37 libc.so.6 0x00003fff871c4774 __libc_start_main + 196
clang version 3.9.0 (trunk 266784) (llvm/trunk 266782)
This failure was introduced in r222906 - Create a new 'flag_enum' attribute,
specifically the change in Sema::ActOnEnumBody:
@@ -13586,10 +13629,8 @@ void Sema::ActOnEnumBody(SourceLocation
BestPromotionType = Context.getPromotedIntegerType(BestType);
else
BestPromotionType = BestType;
- // We don't need to set BestWidth, because BestType is going to be the
type
- // of the enumerators, but we do anyway because otherwise some compilers
- // warn that it might be used uninitialized.
- BestWidth = CharWidth;
+
+ BestWidth = Context.getIntWidth(BestType);
}
I have attached a patch with a potential fix for this issue
--
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/20160419/2ecc2d24/attachment.html>
More information about the llvm-bugs
mailing list