C++: respond to PR comments

This commit is contained in:
Robert Marsh
2019-01-24 10:50:56 -08:00
parent fa02042fda
commit 44d8e6b6e2
2 changed files with 8 additions and 3 deletions

View File

@@ -8,6 +8,11 @@
<p>A function is called with arguments despite having an empty parameter list. This may indicate
that the incorrect function is being called, or that the author misunderstood the function.</p>
<p>In C, a function declared with an empty parameter list `()` is considered to have an unknown
parameter list, and therefore can be called with any set of arguments. To declare a function
which takes no arguments, you must use `(void)` as the parameter list in any forward declarations.
In C++, either style of declaration will be considered to take no arguments.</p>
</overview>
<recommendation>
<p>Call the function without arguments, or call a different function that expects the arguments

View File

@@ -14,12 +14,12 @@ void test() {
not_yet_declared1(1); // BAD
not_yet_declared2(1); // GOOD
declared_empty_defined_with(); // BAD
declared_empty_defined_with(); // BAD [NOT DETECTED]
declared_empty_defined_with(1); // GOOD
int x;
declared_empty_defined_with(&x); // BAD
declared_empty_defined_with(x, x); // BAD
declared_empty_defined_with(&x); // BAD [NOT DETECTED]
declared_empty_defined_with(x, x); // BAD [NOT DETECTED]
}
void not_yet_declared1();