C++ catching dangling reference

前端 未结 7 825
温柔的废话
温柔的废话 2020-12-14 22:02

Suppose the following piece of code

struct S {
    S(int & value): value_(value) {}
    int & value_;
};

S function() {
    int value = 0;
    retur         


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-14 22:23

    You have to use an technology based on compile-time instrumentation. While valgrind could check all function calls at run-time (malloc, free), it could not check just code.

    Depending your architecture, IBM PurifyPlus find some of these problem. Therefore, you should find a valid license (or use your company one) to use-it, or try-it with the trial version.

提交回复
热议问题