1
我希望静态分析器在下面的代码中警告我关于无效右值解引用。如何在clang或cppcheck中执行该操作?如何检查cppcheck或clang中的类型安全?
#include <memory>
using namespace std;
unique_ptr<int> myfunc(void)
{
unique_ptr<int> a(new int(2));
return a;
}
int main()
{
const int& ra = *myfunc();
return 0;
}
这与类型安全无关。 –