[PATCH] D98726: [analyzer] Enabling MallocChecker to take up after SmartPtrModelling
Deep Majumder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 23 21:42:44 PDT 2021
RedDocMD added a comment.
Okay, this is alarming.
The following code yields a leak warning:
#include <iostream>
#include <memory>
struct A {
int field;
A(int f = 0) : field{f} {}
void foo() { std::cout << "Field: " << field << "\n"; }
};
void foo() {
int *raw = new int(10);
std::cout << *raw << "\n";
}
But the following doesn't:
#include <iostream>
#include <memory>
struct A {
int field;
A(int f = 0) : field{f} {}
void foo() { std::cout << "Field: " << field << "\n"; }
};
void foo() {
std::unique_ptr<A> P{new A(10)}; // <-- This is the additional line
int *raw = new int(10);
std::cout << *raw << "\n";
}
So the mere presence of a `unique_ptr` seems to turn off/cripple the `MallocChecker`!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98726/new/
https://reviews.llvm.org/D98726
More information about the cfe-commits
mailing list