[cfe-users] Casting assertion failed

2016-07-31 Thread Daniel Kraut via cfe-users
Hello everyone,

I am quite desperate right now finding a bug in my application. I am using
clang API to travel through its AST a do some static analysis - just
Visitor, no changes. I am getting this:

 /usr/lib/llvm-3.8/include/llvm/Support/Casting.h:237: typename
llvm::cast_retty::ret_type llvm::cast(Y*) [with X = clang::Expr; Y =
clang::Stmt; typename llvm::cast_retty::ret_type = clang::Expr*]:
Assertion `isa(Val) && "cast() argument of incompatible type!"'
failed.
(SIGABRT) (core dumped ...)

Some input is fine, some gets this assertion fail. Does anyone have a hint
what code could raise this assertion fail?

I'm using g++ to compile my app, no special flags just c++11. I have Clang
version 3.8.1 binaries - libclang-dev via Synaptic on my Xubuntu and on my
CentOS I downloaded binaries from web, both gets the same assertion fail.

Thanks everyone who tries to help,
Daniel Kraut
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Casting assertion failed

2016-07-31 Thread don hinton via cfe-users
Hi Daniel:

This is because Expr derives from Stmt, not the other way around, so
casting a Stmt to an Expr might fail.

Try using dyn_cast<> instead and test for null.

hth...
don

On Sun, Jul 31, 2016 at 3:45 AM, Daniel Kraut via cfe-users <
cfe-users@lists.llvm.org> wrote:

> Hello everyone,
>
> I am quite desperate right now finding a bug in my application. I am using
> clang API to travel through its AST a do some static analysis - just
> Visitor, no changes. I am getting this:
>
>  /usr/lib/llvm-3.8/include/llvm/Support/Casting.h:237: typename
> llvm::cast_retty::ret_type llvm::cast(Y*) [with X = clang::Expr; Y =
> clang::Stmt; typename llvm::cast_retty::ret_type = clang::Expr*]:
> Assertion `isa(Val) && "cast() argument of incompatible type!"'
> failed.
> (SIGABRT) (core dumped ...)
>
> Some input is fine, some gets this assertion fail. Does anyone have a hint
> what code could raise this assertion fail?
>
> I'm using g++ to compile my app, no special flags just c++11. I have Clang
> version 3.8.1 binaries - libclang-dev via Synaptic on my Xubuntu and on my
> CentOS I downloaded binaries from web, both gets the same assertion fail.
>
> Thanks everyone who tries to help,
> Daniel Kraut
>
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users