<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Assertion failure compiling template aliases with enums"
href="https://llvm.org/bugs/show_bug.cgi?id=27425">27425</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Assertion failure compiling template aliases with enums
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rcraik@ca.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16237" name="attach_16237" title="Patch with fix">attachment 16237</a> <a href="attachment.cgi?id=16237&action=edit" title="Patch with fix">[details]</a></span>
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>