Re: __gnu_cxx error in OpenSolaris

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2011-05-25 at 14:22 -0400, asyropoulos@xxxxxxx wrote:
> When you buy  screwdrivers, tools in general,. they all conform to 
> standards or else you wouldn't be able to use them. It is that simple.
> A compiler must conform to standards. It must accept only strings
> (programs) that follow the standard.

Ian already mentioned this but I'll reiterate it because I see this all
the time in my work as well: it appears to be a common misunderstanding
of what standards are for and what it means to be a conforming
implementation of a given standard.

If your compiler accepts input that is correct according to the standard
and it correctly generates the proper output as defined by the standard,
then it's a conforming implementation of that standard.

GCC is at least as conforming as any other compiler, that I'm aware of,
to the various standards.  All compilers have small areas where they're
not conforming and GCC does too, but these are being reduced all the
time.


What you are asking for here is something completely different: that the
compiler REJECT any input that does NOT conform exactly to the standard.
That behavior is NOT required in a conforming implementation of the
standard.  The standard does not, and cannot, describe what the compiler
should do when the input invokes undefined behavior... it can emit an
error, or crash, or even actually interpret that behavior and provide
useful results.  If the input is not strictly conforming then nothing
the compiler does can be said to violate the standard, by definition.

So.  You do not have a valid argument based on adherence to the
standard: GCC's behavior is absolutely, completely valid in terms of
what the standard requires and IS a (mostly) conforming
implementation--at any rate, changing the default behavior as you
suggest will not make GCC any MORE conforming than it is today.


You have a good argument to be made here based solely on quality of
implementation grounds: that it would be better, from a QOI point of
view, if the compiler were to by default complain about non-conforming
behavior and require flags to be specified to loosen the interpretation.
I can't disagree with you that _in the abstract_ that would be the
correct behavior.

But here's the thing: GCC was written (originally) before ISO published
the first C standard.  It _predates_ the standard.  At the time the
standard was published in 1989/1990 it was already outdated in various
ways.  Also, because the standard was just published, hardly any C code
actually complied with the standard.  If GCC had adopted a strict
adherence model almost no code would have passed that check.  So GCC
kept its "lax" interpretation as the default but allowed you to ask for
strict interpretations.  Maybe in hindsight a different choice would
have been better... or maybe not.

In any event, what Ian is saying is that the choice was made back then
and it's far too late now to change it.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux