J
Johannes Schaub (litb)
It just happens we are discussing the following:
void f();
void g(int x) {
if(x < 0)
f(x);
else
f(x, x);
}
void f(int x) { }
int main() { f(-1); }
Has this program defined behavior? Name-lookup for "f" necessarily happens
and constructs an expression f that has no prototype. A well defined program
cannot both calls to the same function with different argument numbers if
the function has no prototype so far.
The rule is 6.5.2.2/6: "If the number of arguments does not equal the number
of parameters, the behavior is undefined."
Intuitively I would say that behavior is defined in our case because the
other branch is not evaluated. But how can we conclude this is a formal
manner from the wording?
Thanks for all your insight.
void f();
void g(int x) {
if(x < 0)
f(x);
else
f(x, x);
}
void f(int x) { }
int main() { f(-1); }
Has this program defined behavior? Name-lookup for "f" necessarily happens
and constructs an expression f that has no prototype. A well defined program
cannot both calls to the same function with different argument numbers if
the function has no prototype so far.
The rule is 6.5.2.2/6: "If the number of arguments does not equal the number
of parameters, the behavior is undefined."
Intuitively I would say that behavior is defined in our case because the
other branch is not evaluated. But how can we conclude this is a formal
manner from the wording?
Thanks for all your insight.