[LLVMbugs] [Bug 6733] New: template class with default arg assigned from enum causes assert

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 28 18:15:44 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=6733

           Summary: template class with default arg assigned from enum
                    causes assert
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: alexmac at adobe.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


The following code compiles with g++ but causes an assert when compiled with
clang:

#include <iostream>
template <class T>
class bar {
public: enum { kSomeConst = 128 };
    bar(int32_t x = kSomeConst) {}
};
int main() {
    bar<int> tmp;
}

Assertion failed:
(getContext().getCanonicalType(ArgType.getNonReferenceType()). getTypePtr() ==
getContext().getCanonicalType(Arg->getType()).getTypePtr() && "type mismatch in
call argument!"), function EmitCallArgs, file
/p4/llvm-trunk/tools/clang/lib/CodeGen/CodeGenFunction.h, line 1327.
0  clang             0x0000000100ec8372 PrintStackTrace(void*) + 34
1  clang             0x0000000100ec8b5e SignalHandler(int) + 622
2  libSystem.B.dylib 0x00007fff8649feaa _sigtramp + 26
3  libSystem.B.dylib 0x00007fff5fbfa610 _sigtramp + 3648366464
4  libSystem.B.dylib 0x00007fff8651be74 __pthread_markcancel + 0
5  clang             0x00000001001977d0 void
clang::CodeGen::CodeGenFunction::EmitCallArgs<clang::FunctionProtoType>(llvm::SmallVector<std::pair<clang::CodeGen::RValue,
clang::QualType>, 16u>&, clang::FunctionProtoType const*,
clang::ConstExprIterator, clang::ConstExprIterator) + 1008
6  clang             0x000000010019f811
clang::CodeGen::CodeGenFunction::EmitCXXMemberCall(clang::CXXMethodDecl const*,
llvm::Value*, clang::CodeGen::ReturnValueSlot, llvm::Value*, llvm::Value*,
clang::ConstExprIterator, clang::ConstExprIterator) + 369
7  clang             0x0000000100163348
clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl
const*, clang::CXXCtorType, llvm::Value*, clang::ConstExprIterator,
clang::ConstExprIterator) + 376
8  clang             0x000000010019d0b7
clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(llvm::Value*,
clang::CXXConstructExpr const*) + 647
9  clang             0x00000001001983b2 (anonymous
namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr
const*) + 226
10 clang             0x000000010019ae74 clang::StmtVisitor<(anonymous
namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) + 2660
11 clang             0x000000010019b92b
clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, llvm::Value*,
bool, bool, bool, bool) + 139
12 clang             0x000000010017fbcd
clang::CodeGen::CodeGenFunction::EmitLocalBlockVarDecl(clang::VarDecl const&) +
10525
13 clang             0x0000000100180721
clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) + 497
14 clang             0x0000000100208dfb
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) + 171
15 clang             0x000000010020f9eb
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 171
16 clang             0x000000010020cad0
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 48
17 clang             0x000000010020f6fb
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, llvm::Value*, bool) + 267
18 clang             0x000000010020fa27
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 231
19 clang             0x000000010020cad0
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 48
20 clang             0x000000010023f66d
clang::CodeGen::CodeGenFunction::GenerateCode(clang::CodeGen::GlobalDecl,
llvm::Function*) + 1565
21 clang             0x0000000100247fef
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::CodeGen::GlobalDecl)
+ 687
22 clang             0x000000010024948b
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::CodeGen::GlobalDecl)
+ 347
23 clang             0x00000001002496d9
clang::CodeGen::CodeGenModule::EmitGlobal(clang::CodeGen::GlobalDecl) + 457
24 clang             0x0000000100249bc2
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 674
25 clang             0x000000010025b9ac (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 60
26 clang             0x000000010003a56e (anonymous
namespace)::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 158
27 clang             0x000000010026c542 clang::ParseAST(clang::Preprocessor&,
clang::ASTConsumer*, clang::ASTContext&, bool, bool,
clang::CodeCompleteConsumer*) + 274
28 clang             0x000000010003e579
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 377
29 clang             0x0000000100022fb9 cc1_main(char const**, char const**,
char const*, void*) + 2249
30 clang             0x0000000100025cf2 main + 2322
31 clang             0x0000000100020a88 start + 52
32 clang             0x000000000000001d start + 4294833609
Stack dump:
0.    Program arguments: /p4/llvm-trunk-build/Release/bin/clang -cc1 -triple
x86_64-apple-darwin10.0.0 -S -disable-free -main-file-name avmplusList.cpp
-pic-level 1 -mdisable-fp-elim -munwind-tables -target-cpu core2 -resource-dir
/p4/llvm-trunk-build/Release/lib/clang/1.5 -fmessage-length 217
-stack-protector 1 -fblocks -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o
/var/folders/ny/nyOMoi2iGUayncIufU3gZU+++TI/-Tmp-/cc-xbhbBV.s -x c++
avmplusList.cpp 
1.    <eof> parser at end of file
2.    avmplusList.cpp:7:5: LLVM IR generation of declaration 'main'
3.    avmplusList.cpp:7:5: Generating code for declaration 'main'
4.    avmplusList.cpp:7:12: LLVM IR generation of compound statement ('{}')
clang: error: compiler command failed due to signal 6 (use -v to see
invocation)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list