-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[-Wunsafe-buffer-usage] Add unique_ptr <T[]> accesses #156773
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
Changes from 11 commits
927b2f6
bae5f2e
284c262
980a75e
11fc596
800d393
4c95972
38a2d44
dd1ab78
aacc510
f074fd0
5bc6580
766be17
eb9afef
efb19b6
7cefe30
6cf2c9f
f805faf
db8a2bc
9d597ed
2b823cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,20 @@ void test_unclaimed_use(int *p) { // expected-warning{{'p' is an unsafe pointer | |
p[5] = 5; // expected-note{{used in buffer access here}} | ||
} | ||
|
||
namespace std { | ||
shreya-jain marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
inline namespace __1 { | ||
template <class T> class unique_ptr { | ||
public: | ||
T &operator[](long long i) const; | ||
}; | ||
} // namespace __1 | ||
} // namespace std | ||
|
||
void basic_unique_ptr() { | ||
|
||
std::unique_ptr<int[]> p1; | ||
p1[0]; // expected-warning{{direct access using operator[] on std::unique_ptr<T[]> is unsafe due to lack of bounds checking}} | ||
shreya-jain marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
// CHECK: Root # 1 | ||
// CHECK: |- DeclRefExpr # 4 | ||
// CHECK: |-- UnaryOperator(++) # 1 | ||
|
Uh oh!
There was an error while loading. Please reload this page.