Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3345624
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:12:28+00:00 2026-05-18T01:12:28+00:00

!Disclaimer! : Please note that I am talking about untagged declarations. I know it’s

  • 0

!Disclaimer!: Please note that I am talking about untagged declarations. I know it’s a possibly informal term and what I mean by it is that the declaration is not a typedef and it does not declare an object of the anonymous type. In these cases everything is clear.

Question 1:
which of the following is a well-formed C++ program? (multiple-choice)

//One
int main(){
   struct{}; //or class{}; should be the same
}
//Two  
int main(){
   enum{}; 
}
//Three
int main(){
   union{}; 
}

Remarks:
MSVC9.0 accepts all three. On number one it gives a warning. On number two and three we get 0 errors and 0 warnings. The online comeau accepts only number three, numbers one and two fail to compile with a diagnostic message “declaration does not declare anything”. If, in number two, the anonymous enumeration contains at least one enumerator, number two is rightfully accepted by the comeau compiler.

If the comeau compiler is correct, and this is the standard behavior, then I see some inconsistency in it. I can understand why number one should be rejected. I would also understand why number two should be rejected(declares nothing), but in this case number three should be rejected as well. And if number three should not be rejected, then the only difference I see with number one is that the scope of the members of an anoymous union is the outer scope. But that is also the case with enums, so, my claim is that should number three be accepted then so should number two.

Question 2:
If comeau is correct, what considerations am I missing in my above judgment?

P.S. I have written an email to comeau support. I will post their answer as soon as I get it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:12:28+00:00Added an answer on May 18, 2026 at 1:12 am

    None of it is legal. See [dcl.dcl] paragraph 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer Yes, I am fully aware that what I am asking about is totally
Disclaimer, I know very little about Rails. I'll try to be succinct. Given the
Disclaimer: the following is a sin against XML. That's why I'm trying to change
Disclaimer: please do not bother reading this long post unless you are an embedded
Disclaimer: i still suck at writing scripts please be gentle if this is a
[Disclaimer: I am new to PHP, and I am just learning, so please no
Disclaimer: I did check other questions that seemed related, but this one is much
Disclaimer Please don't just vote to close this because the title looks subjective, and
Background / Disclaimer First of all, please feel free to skip this entirely if
Disclaimer: Sensible semantics do dictate that the LHS of as behaving differently depending on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.