Skip to content

invalid cast assertion #10454

@llvmbot

Description

@llvmbot
Bugzilla Link 10082
Resolution FIXED
Resolved on Jun 08, 2011 17:10
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic

Extended Description

clang++ -O2 a.cc -c
fails with an invalid cast assertion. This may or may not be related to bug 8769 (I discovered this one when I finally removed the workaround for 8769).

template struct array {
float _M_instance[3] attribute((aligned));
const float& operator[](int __n) const {
return _M_instance[__n];
}
};
struct PointC3 {
array base;
const float & x() const {
return base[0];
}
};
struct Point_3 : public PointC3 {
};
struct Equal_3 {
bool operator()(const PointC3 &p, const PointC3 &q) const {
return p.x() == q.x();
}
};
Equal_3 equal_3_object();
inline bool operator==(const Point_3& p, const Point_3& q) {
return equal_3_object()(p, q);
}
Point_3 f();
int main() {
f() == f();
}

clang: /data/repos/llvm/lib/VMCore/Instructions.cpp:2079: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, const llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
0 clang 0x0000000001ab601f
1 clang 0x0000000001ab6b5a
2 libpthread.so.0 0x00007ff490785020
3 libc.so.6 0x00007ff48fa7f3d5 gsignal + 53
4 libc.so.6 0x00007ff48fa82650 abort + 384
5 libc.so.6 0x00007ff48fa78581 __assert_fail + 241
6 clang 0x00000000019bfcad
7 clang 0x00000000007fca66 llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type const*, llvm::Twine const&) + 118
8 clang 0x0000000001779276
9 clang 0x0000000001779c84
10 clang 0x0000000001779b4c
11 clang 0x0000000001779a01
12 clang 0x000000000177e339
13 clang 0x0000000001780f49
14 clang 0x00000000019e296f llvm::FPPassManager::runOnFunction(llvm::Function&) + 655
15 clang 0x0000000001862727
16 clang 0x0000000001864aee
17 clang 0x00000000019e2467 llvm::MPPassManager::runOnModule(llvm::Module&) + 551
18 clang 0x00000000019e25cb llvm::PassManagerImpl::run(llvm::Module&) + 187
19 clang 0x00000000007cf0f7 clang::EmitBackendOutput(clang::Diagnostic&, clang::CodeGenOptions const&, clang::TargetOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 2967
20 clang 0x00000000007cce8b clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 251
21 clang 0x000000000092362f clang::ParseAST(clang::Sema&, bool) + 351
22 clang 0x00000000007cba94 clang::CodeGenAction::ExecuteAction() + 68
23 clang 0x00000000006ca233 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 371
24 clang 0x00000000006a306a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1290
25 clang 0x000000000069783b cc1_main(char const**, char const**, char const*, void*) + 779
26 clang 0x00000000006a1f43 main + 7667
27 libc.so.6 0x00007ff48fa6bead __libc_start_main + 253
28 clang 0x0000000000697349
Stack dump:
0. Program arguments: /tmp/clang/inst/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name a.cc -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21.51.20110523 -momit-leaf-frame-pointer -coverage-file a.o -resource-dir /tmp/clang/inst/bin/../lib/clang/3.0 -O2 -fdeprecated-macro -ferror-limit 19 -fmessage-length 0 -fcxx-exceptions -fexceptions -fgnu-runtime -fdiagnostics-show-option -o a.o -x c++ a.cc

  1.  <eof> parser at end of file
    
  2.  Per-module optimization passes
    
  3.  Running pass 'CallGraph Pass Manager' on module 'a.cc'.
    
  4.  Running pass 'Scalar Replacement of Aggregates (SSAUp)' on function '@main'
    

clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions