class Test
{
;
int x;
};
Is this perfectly legal and portable?
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.
From my reading of the standard, this is not allowed.
If you look at the grammar definition only, it seems to allow it. The relevant parts are:
The member-specification is what appears between the
{ ... }in the class declaration.member-specification is a sequence of member-declaration and access specifiers. One possible form for a member-declaration is:
Since everything before the semicolon is optional, it looks like it’s allowed to have an empty
member-declaration, which consists of only a semicolon.
However, 9.2/1 says:
Since an empty member-declaration does not declare at least one member of a class, it seems that this is not standard-compliant, even if some compilers accept it.