Is the following code legal in C++?
void f(void* = 0)
{}
int main()
{
f();
}
Which page of the C++ standard states that this usage is legal?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, it’s legal.
There is no standard wording to allow this combination of features specifically; there simply isn’t any to disallow it, either.
Default argument syntax applies to function parameters in a parameter-declaration:
…and function parameters in a parameter-declaration may be unnamed:
There is even an example of this usage under 8.3.6/4 (though examples are not normative text, so this cannot be used to prove anything concretely).