File tree Expand file tree Collapse file tree
src/Likely Bugs/Likely Typos
test/query-tests/Likely Bugs/Likely Typos/FutileParams Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88<p >A function is called with arguments despite having an empty parameter list. This may indicate
99that 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
Original file line number Diff line number Diff 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
2525void not_yet_declared1 ();
You can’t perform that action at this time.
0 commit comments