[LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp?
atrick at apple.com
Thu Oct 23 20:32:20 PDT 2014
> On Oct 17, 2014, at 5:21 PM, Liang Wang <netcasper at gmail.com> wrote:
> Here is the code in IndVarSimplify.cpp.
> SmallVector<WeakVH, 16> DeadInsts;
> while (!DeadInsts.empty())
> if (Instruction *Inst =
> RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
> Since DeadInsts.pop_back_val() is WeakVH which could hold a NULL
> pointer, the expression, &*DeadInsts.pop_back_val(), could be &*NULL.
> Then NULL pointer is dereferenced here.
> I wrote a small test case and it works just fine. But is this a
> well-defined behavior in the standard?
Try clang-dev or a c++ list for questions about the standard.
I think it would have been nicer to write (Value*)DeadInsts.pop_back_val()
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev