Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44d8e6b

Browse files
author
Robert Marsh
committed
C++: respond to PR comments
1 parent fa02042 commit 44d8e6b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/FutileParams.qhelp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<p>A function is called with arguments despite having an empty parameter list. This may indicate
99
that the incorrect function is being called, or that the author misunderstood the function.</p>
1010

11+
<p>In C, a function declared with an empty parameter list `()` is considered to have an unknown
12+
parameter list, and therefore can be called with any set of arguments. To declare a function
13+
which takes no arguments, you must use `(void)` as the parameter list in any forward declarations.
14+
In C++, either style of declaration will be considered to take no arguments.</p>
15+
1116
</overview>
1217
<recommendation>
1318
<p>Call the function without arguments, or call a different function that expects the arguments

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/FutileParams/test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ void test() {
1414
not_yet_declared1(1); // BAD
1515
not_yet_declared2(1); // GOOD
1616

17-
declared_empty_defined_with(); // BAD
17+
declared_empty_defined_with(); // BAD [NOT DETECTED]
1818
declared_empty_defined_with(1); // GOOD
1919

2020
int x;
21-
declared_empty_defined_with(&x); // BAD
22-
declared_empty_defined_with(x, x); // BAD
21+
declared_empty_defined_with(&x); // BAD [NOT DETECTED]
22+
declared_empty_defined_with(x, x); // BAD [NOT DETECTED]
2323
}
2424

2525
void not_yet_declared1();

0 commit comments

Comments
 (0)