[LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp? (original) (raw)
Andrew Trick atrick at apple.com
Thu Oct 23 20:32:20 PDT 2014
- Previous message: [LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp?
- Next message: [LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Oct 17, 2014, at 5:21 PM, Liang Wang <netcasper at gmail.com> wrote:
Hi, Here is the code in IndVarSimplify.cpp. SmallVector<WeakVH, 16> DeadInsts;
while (!DeadInsts.empty()) if (Instruction *Inst = dyncastornull(&*DeadInsts.popbackval())) RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI); Since DeadInsts.popbackval() is WeakVH which could hold a NULL pointer, the expression, &*DeadInsts.popbackval(), 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() -Andy
Thanks, Liang
LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
- Previous message: [LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp?
- Next message: [LLVMdev] Dereferencing NULL pointer in IndVarSimplify.cpp?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]