Page 1 of 1
Does G++ follow 98 standard?
Posted: Sun Jun 01, 2008 10:32 pm
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.
Posted: Sun Jun 01, 2008 11:14 pm
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.
Re: Does G++ follow 98 standard?
Posted: Mon Jun 02, 2008 1:08 am
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++...)
Posted: Mon Jun 02, 2008 3:19 am
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.
Posted: Mon Jun 02, 2008 2:59 pm
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.
Posted: Wed Jun 04, 2008 11:53 pm
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.