C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Which compiler is correct?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
SK
Guest





PostPosted: Wed Aug 13, 2003 4:33 pm    Post subject: Which compiler is correct? Reply with quote



Consider this code:

class A{
public:

class {
public:
int i;
};

};

int main ()
{
}

This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.

What does the standard have to say about unnamed nested classes?

Thanks.


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Daniel Frey
Guest





PostPosted: Wed Aug 13, 2003 5:45 pm    Post subject: Re: Which compiler is correct? Reply with quote



SK wrote:
Quote:
What does the standard have to say about unnamed nested classes?

Comeau is correct. The only valid use of unnamed classes/structs is to
declare a typedef or name a variable, which you haven't done in your
example. Whether or not the class is a nested class is irrelevant.

Regards, Daniel

--
Daniel Frey

aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: [email]daniel.frey (AT) aixigo (DOT) de[/email], web: http://www.aixigo.de

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Carl Daniel
Guest





PostPosted: Thu Aug 14, 2003 6:55 pm    Post subject: Re: Which compiler is correct? Reply with quote



"SK" wrote:
Quote:
Consider this code:

class A{
public:

class {
public:
int i;
};

};

int main ()
{
}

This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.

VC6, VC7 and VC7.1 flag this as an error if you compile with -Za (disable
extensions), and gives a wanring (non-standard extension used) if you
compile with -W4.

Comeau is correct according to the standard.

-cd

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
llewelly
Guest





PostPosted: Sat Aug 16, 2003 5:07 pm    Post subject: Re: Which compiler is correct? Reply with quote

[email]sk (AT) sk (DOT) com[/email] ("SK") writes:

Quote:
Consider this code:

class A{
public:

class {
public:
int i;
};

};

int main ()
{
}

This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.

g++ -pedantic -W -Wall cl2.cc
cl2.cc:7: warning: ISO C++ prohibits anonymous structs

If you want an error, use -pedantic-errors.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.