-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-tidy] False positive diagnostic for NewDeleteLeaks #122405
Comments
@llvm/issue-subscribers-clang-tidy Author: Chuanqi Xu (ChuanqiXu9)
Reproducer:
#include <vector>
#include <memory>
void RuleParseCommon() { std::vector{std::make_shared<int>()}; } Reproducer reduced by cvise: namespace std {
template <class E> struct initializer_list {
const E *begin;
const E *end;
};
template <typename _Tp> struct vector {
vector(initializer_list<_Tp>);
};
struct _Sp_counted_base {};
struct __shared_count {
__shared_count(int, int) {
auto __pi = new _Sp_counted_base;
_M_pi = __pi;
}
~__shared_count();
_Sp_counted_base *_M_pi;
};
int _M_ptr;
struct __shared_ptr {
template <typename _Alloc>
__shared_ptr(_Alloc __tag) : _M_refcount(_M_ptr, __tag) {}
__shared_count _M_refcount;
};
struct shared_ptr : __shared_ptr {
shared_ptr(int __tag) : __shared_ptr(__tag) {}
};
int allocate_shared___a;
shared_ptr allocate_shared() { return allocate_shared___a; }
shared_ptr make_shared() { return allocate_shared(); }
} // namespace std
using std::vector;
void RuleParseCommon() { vector{std::make_shared()}; } Command:
we got:
|
@llvm/issue-subscribers-clang-static-analyzer Author: Chuanqi Xu (ChuanqiXu9)
Reproducer:
#include <vector>
#include <memory>
void RuleParseCommon() { std::vector{std::make_shared<int>()}; } Reproducer reduced by cvise: namespace std {
template <class E> struct initializer_list {
const E *begin;
const E *end;
};
template <typename _Tp> struct vector {
vector(initializer_list<_Tp>);
};
struct _Sp_counted_base {};
struct __shared_count {
__shared_count(int, int) {
auto __pi = new _Sp_counted_base;
_M_pi = __pi;
}
~__shared_count();
_Sp_counted_base *_M_pi;
};
int _M_ptr;
struct __shared_ptr {
template <typename _Alloc>
__shared_ptr(_Alloc __tag) : _M_refcount(_M_ptr, __tag) {}
__shared_count _M_refcount;
};
struct shared_ptr : __shared_ptr {
shared_ptr(int __tag) : __shared_ptr(__tag) {}
};
int allocate_shared___a;
shared_ptr allocate_shared() { return allocate_shared___a; }
shared_ptr make_shared() { return allocate_shared(); }
} // namespace std
using std::vector;
void RuleParseCommon() { vector{std::make_shared()}; } Command:
we got:
|
I could not reproduce the issue: https://compiler-explorer.com/z/oMWdPW66a |
FYI I had a look at the preprocessed reduced version, and that of course reproduces the issue. However, without seeing the original case it's hard to tell if it's because the reduction actually implanted the leak due to the cuts it made or because it originally had the leak. |
Reproducer:
Reproducer reduced by cvise:
Command:
we got:
The text was updated successfully, but these errors were encountered: