Skip to content

Commit

Permalink
精炼词句
Browse files Browse the repository at this point in the history
改用更准确的 `new[]`, fix #42
  • Loading branch information
brotherbeer authored Dec 29, 2023
1 parent cacc880 commit 5d1aeaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion c-cpp-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
"ID_insufficientDelete": {
"checkPoint": "用 delete 释放数组不可漏写中括号",
"level": "error",
"comment": "用 new 分配的数组应该用 delete[] 释放,不可漏写中括号,否则导致标准未定义的行为。",
"comment": "用 new[] 分配的数组应该用 delete[] 释放,不可漏写中括号,否则导致标准未定义的行为。",
"tag": "resource",
"related": "ID_excessiveDelete",
"standard": "ISO/IEC 14882:2003 5.3.5(2)-undefined,ISO/IEC 14882:2011 5.3.5(2)-undefined,ISO/IEC 14882:2017 8.3.5(2)-undefined",
Expand Down
4 changes: 2 additions & 2 deletions c-cpp-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,7 @@ ID_insufficientDelete       :drop_of_blood: resource er

<hr/>

用 new 分配的数组应该用 delete\[\] 释放,不可漏写中括号,否则导致标准未定义的行为。
用 new\[\] 分配的数组应该用 delete\[\] 释放,不可漏写中括号,否则导致标准未定义的行为。

示例:
```
Expand Down Expand Up @@ -2547,7 +2547,7 @@ char* pc = new char; // Non-compliant
bool b = false; // Compliant
char c = 0; // Compliant
```
用 new 分配数组时方括号被误写成小括号,或使用 unique\_ptr 等智能指针时遗漏了数组括号也是常见笔误,如:
用 new\[\] 分配数组时方括号被误写成小括号,或使用 unique\_ptr 等智能指针时遗漏了数组括号也是常见笔误,如:
```
int* pi = new int(32); // Non-compliant
auto ui = make_unique<int>(32); // Non-compliant
Expand Down

0 comments on commit 5d1aeaa

Please sign in to comment.