__gnu_cxx error in OpenSolaris
Jonathan Wakely
jwakely.gcc@gmail.com
Fri May 20 06:54:00 GMT 2011
On 20 May 2011 07:20, Dr. David Kirkby wrote:
> On 05/19/11 09:09 PM, Jonathan Wakely wrote:
>>
>> On 19 May 2011 20:03, David Kirkby<david.kirkby@onetel.net> wrote:
>
>> I thought we were talking about C++ (my first clue was the subject of
>> the thread and your mention of "GNU C++")
>
>> Throughout your reply you only refer to C, which I'm not qualified or
>> interested enough to comment on.
>
> But for many practical purposes C++ is a superset of C, so g++ inherits the
> same GNUims as gcc.
Some, but not all of them. G++ is not a superset of the C compiler in
GCC, they're separate front ends.
On the other hand, many C++ extensions have been removed over the years.
See
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Deprecated-Features.html
and
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Backwards-Compatibility.html
which support my point about removing non-standard extensions.
As for the other C++ extensions, three of them are now part of the
upcoming C++ standard:
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/C_002b_002b-Extensions.html
That's why I say the trend is to remove non-standard extensions in the
C++ front end, can you see how I can say that now?
> For example:
>
> #include <iostream>
> using namespace std;
>
> int main() {
> int a=0b1111111;
> cout << a;
> }
>
> compiles with g++, but is not valid C++.
>
> There's not even a warning if -Wall is used
Well of course not, RTFM.
If you use -pedantic you get a warning.
> drkirkby@hawk:~$ g++ -Wall test.cc
> drkirkby@hawk:~$
>
> The Sun compiler quickly identifies this as invalid C++ code.
>
> drkirkby@hawk:~$ CC test.cc
> "test.cc", line 5: Error: 0b is not a valid constant.
> "test.cc", line 5: Error: Badly formed expression.
> 2 Error(s) detected.
>
>> I'm very interested in making G++ conform to the C++ standard as well
>> as possible and only objected to the assertion that G++ users don't
>> care about writing standard C++.
>
> My point is the GNU compilers allow constructs which are not standard.
So do all compilers so your point is pretty pointless.
e.g. the Sun compiler allows
struct X {
mutable int& i;
};
but that's ill-formed (gcc accepted it until 4.6 too, but I fixed it.)
G++ is far stricter and more standard conforming than the Sun
compiler. Additionally it accepts some extensions, but most of them
can be disabled with -pedantic-errors if you don't want them.
> Anyone starting a C++ project and wishing for it to be standard C++, should
> not use g++.
Now you sound like a troll. I'd ignore you, but I don't want to leave
a ridiculous statement like that unchallenged in the archives of this
list.
I've been starting C++ projects for years using G++ and it's not done
me or my code any harm.
More information about the Gcc-help
mailing list