Does G++ follow 98 standard?

Programming, for all ages and all languages.
Post Reply
User avatar
Pinkfloyd
Posts: 4
Joined: Sun May 25, 2008 7:53 pm

Does G++ follow 98 standard?

Post by Pinkfloyd »

Is G++ follow 100% of 98 compliance or does it not follow some obscure features of the standard???I'm pretty new to C++ from C and I know gcc is like 100% for C90 standard.I'm just asking because i hear C++ compilers are generally less compliant.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

G++ is rather 99% compliant (as of 4.3.0). IT does not support the export keyword properly. There are also probably one or two other minor issues that don't work quite well.

MSVC is about 98% compliant (as of 8.0, haven't tried 9.0); it makes a few more mistakes than GCC but not that much. I personally have only hit one fairly large thing, it doesn't support a copy constructor from const and a copy constructor from non-const reference in one class.

There are compilers that are more compliant, but they're far from common. I believe Comeau's compiler is the most well-known compiler to support export.


C99 is the best in GCC. MSVC explicitly doesn't support it and doesn't support the features (VLA), the headers (inttypes.h) and so forth.


As for c++0x, that's another story. MSVC doesn't do any yet as far as I know. GCC has an experimental mode in 4.3 but it has bugs because it's the first release to have it. Just yesterday evening I had a discussion with bluecode as

Code: Select all

template <typename A>
class B {};
template <typename C
class D {};
B<D<void()>> some_var;
doesn't compile, but if you insert a space between the two >'s, it does work. There's supposed to be a C++0x change that makes it work with the two joined together.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Does G++ follow 98 standard?

Post by Solar »

Pinkfloyd wrote:Is G++ follow 100% of 98 compliance or does it not follow some obscure features of the standard???
If you are looking for full compliance, your choices are limited. To my knowledge, only the EDG compiler frontend (also powering the Comeau compiler) in combination with the Dinkumware libraries gives you that (bugs nonwithstanding).
...I know gcc is like 100% for C90 standard.
Don't know about C90, but it's still lacking in some places for C99. (Too bad there doesn't seem to exist such a table for C++...)
Last edited by Solar on Mon Jun 02, 2008 3:55 am, edited 1 time in total.
Every good solution is obvious once you've found it.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

As for c++0x, that's another story. MSVC doesn't do any yet as far as I know. GCC has an experimental mode in 4.3 but it has bugs because it's the first release to have it. Just yesterday evening I had a discussion with bluecode as

Code: Select all

template <typename A>
class B {};
template <typename C
class D {};
B<D<void()>> some_var;
doesn't compile, but if you insert a space between the two >'s, it does work. There's supposed to be a C++0x change that makes it work with the two joined together.
That's often cited as the biggest grammar ambiguity in C++. The lexer treats the two >'s as ">>", which is a right shift.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Post by Colonel Kernel »

JamesM wrote:That's often cited as the biggest grammar ambiguity in C++. The lexer treats the two >'s as ">>", which is a right shift.
It's probably the second biggest grammar ambiguity. #1 IMO is C++'s most vexing parse as described by Scott Meyers in his book "Effective STL". In a nutshell, sometimes an expression that declares a local variable and calls a constructor on it in a single line looks syntactically like a function definition.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

JamesM wrote:
As for c++0x, that's another story. MSVC doesn't do any yet as far as I know. GCC has an experimental mode in 4.3 but it has bugs because it's the first release to have it. Just yesterday evening I had a discussion with bluecode as

Code: Select all

template <typename A>
class B {};
template <typename C
class D {};
B<D<void()>> some_var;
doesn't compile, but if you insert a space between the two >'s, it does work. There's supposed to be a C++0x change that makes it work with the two joined together.
That's often cited as the biggest grammar ambiguity in C++. The lexer treats the two >'s as ">>", which is a right shift.
The point of my comment was, c++0x explicitly says "the >> without space now *works* and the compiler writer will do whatever it takes to make it work". GCC still doesn't work though.

I quite agree on the most vexing parse.
Post Reply