Link to home
Start Free TrialLog in
Avatar of Axter
AxterFlag for United States of America

asked on

null statement at the end of namespace scope

namespace A
(
};

Is it an error to have a null statement at the end of a namespace scope, and if so, where in the standards does it defined this as an error?
Avatar of jkr
jkr
Flag of Germany image

Hmm - VC++ doesn't complain, g++ doesn't complain, and I cannot see any harm in doing that...
Avatar of Axter

ASKER

>>Hmm - VC++ doesn't complain, g++ doesn't complain, and I
>>cannot see any harm in doing that...

I don't see any harm in it either, and previously, I've never seen a compiler complain about it.
My problem is that I'm porting code to Unix platform, and I'm using stupid compiler that reports this as an error.

I've complain to the vendor of the compiler, and the vendor stated that the code was erroneous, and the compiler is correct to report this as an error.
His only referrence was the following newsgroup link:
http://groups.google.com/groups?q=namespace+semicolon+%22null+statement%22+g
Avatar of jhance
jhance

So when did newgroup postings become authoritative as a LRM?
The way I interpret the article is that

namespace A {
;
}

would be incorrect, as the namespace scope (strictly speaking) ends with the closing bracket...
Just to add that neither VC++ nor g++ complain about

namespace A {
;
}

either...
Avatar of Axter

ASKER

Every compiler I've used always ignored null statement, ALMOST regardless of were it's located.

The section 6.2 of the C++ standard, states the following:
An expression statement with
the expression missing is called a null statement. [Note: Most statements are expression statements—
usually assignments or function calls. A null statement is useful to carry a label just before the } of a compound
statement and to supply a null body to an iteration statement such as a while statement (6.5.1). ]

Then section 6.2 states the following:
[Note: a declaration is a statement (6.7). ]

I interpret that as contridicting what the newsgroup link states.

Furthermore, I can not find any where in the standard where it states that a null statement is not allowed after a namespace scope.
Avatar of Axter

ASKER

>>So when did newgroup postings become authoritative as a >>LRM?
That's the first thing I said when I realized the link was a newsgroup link.
You'd think they could at least refer to a specific item in the LRM.  Even if their INTERPRETATION of the standard is questionable, at least they could claim that their interpretation is reasonable.
The namespace definition in the std does not end with a semi colon therefor it's illegal. I find the simplest interpretation is usually the best.
ONOH, there's no restrictions on empty simple-declarations inside the translation unit... So one could argue that the semicolon is valid (although, I', fairly certain that it's not a null-statement but a null-declaration).
Avatar of Axter

ASKER

>>that it's not a null-statement but a null-declaration).

According to the standards, a declaration is a statement.  

Therefore, a null-declaration is a null-statement.
BTW - the "null statement" is not part of the NS anyway (IMHO), as the namespace scope (strictly speaking) ends with the closing bracket...
Avatar of Axter

ASKER

jkr,
I'm not sure what you mean by NS?  Namespace??? Null-Statement???

I know that the null-statement is not needed.  What I'm trying to determine is if the standards prohibit a null-statement from been placed after a namespace.
In this case, NS == NameSpace :o)
Dear Axter

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to

     "refund the points and PAQ at zero points"

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Avatar of Axter

ASKER

>>I think you forgot this question. I will ask Community
>>Support to close it unless you finalize it within 7 days.

I didn't forget it.  I just couldn't delete it.
The delete option is gone.
It seems that once someone post a comment, you no longer have the option to delete the question.

That seems to me to be a maintanance nightmare.
ASKER CERTIFIED SOLUTION
Avatar of Mindphaser
Mindphaser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial