Hi All, Value* V; Value* V2; BasicBlock * BB; unsigned j; ///number of cases .... //insert V , V2, j and BB SwitchInst* sw= builder.CreateSwitch(V, BB, j); ConstantInt * CI= dyn_cast<ConstantInt>(V2); sw-> addCase( CI , BB); At last step there is Program received signal SIGSEGV, Segmentation fault. What is wrong in the code? Thanks in advance -- * Rasha Salah Omar Msc Student at E-JUST Demonestrator at Faculty of Computers and Informatics Benha University* * e-mail: rasha.omar at ejust.edu.eg* P* Please consider the environment before printing this email.* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130822/4946e9de/attachment.html>
Hi Rasha,> What is wrong in the code?Your best bet is to run a debugger and see if the variables have values you expect just before that last call, and then look at what's causing the segfault in LLVM (null pointer?) code and work out where the first place it's not doing what you expect is. Cheers. Tim.
On 8/22/13 4:01 AM, Tim Northover wrote:> Hi Rasha, > >> What is wrong in the code? > Your best bet is to run a debugger and see if the variables have > values you expect just before that last call, and then look at what's > causing the segfault in LLVM (null pointer?) code and work out where > the first place it's not doing what you expect is.You may also want to use cast<> instead of dyn_cast<> if you expect the result of dyn_cast<> to be non-NULL. cast<> will assert that its result is non-NULL. -- John T.> Cheers. > > Tim. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev