This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fobey-inline (was Re: gcc and inlining)
- From: dewar at gnat dot com (Robert Dewar)
- To: dewar at gnat dot com, echristo at redhat dot com
- Cc: Richard dot Earnshaw at arm dot com, aph at redhat dot com, gcc at gcc dot gnu dot org
- Date: Thu, 13 Mar 2003 20:11:14 -0500 (EST)
- Subject: Re: -fobey-inline (was Re: gcc and inlining)
> This is ridiculous, and absolutely unsupportable. There's no way that we
> can promise the behavior that every user that decides not to program to
> the various language standards will get the behavior that they expect -
> not unless you have a patch to enable the compiler to read the user's
> mind.
If this seems ridiculous and absolutely unsupportable, then I can only say you
must not have spent much time in the real world of supplying real compilers to
real application developers. If you take an adamant "follow-the-standard-or-else"
point of view, you won't get sued, but you will cut down your customer base.
Finding the right balance between completely ignoring requirements outside the
standard, and trying to meet every users request for specific undefined behavior
is not at all easy, but it is part of the job in real world compiler writing.
For example, in the Ada standard, if you write
a := x / y;
where y is 1.0, and Machine_Overflows is false for the floating-point type in
question, then the result is "unspecified". This means that the compiler could
generate code to send denial-of-service-attacks to the internet root servers,
and you would not be violating the standard, but you would not get many
customers for your compiler. What users would expect here on an IEEE machine
is to get infinities, even though the Ada RM says nothing about this possibility.
I am not at ALL saying that everytime some C programmer writes carelessly
non-compliant code (e.g. assuming that an int is the same length as a pointer)
should be accomodated with switches or special behavior of the compiler. That
would indeed be "ridiculous and absolutely unsupportable".
But it is also "ridiculous and absolutely unsupportable" to maintain that a compiler
has no responsibilities at all for generating reasonable code in some situations
that are outside the scope of the standard.
This is really similar to performance requirements. It is perfectly standard
compliant to do muptlication using a recursive routine that does it by adding
and subtracting one. But It is not a reasonable approach, even though it is
conforming. Standards tell part of the story of how you must implement a c
compiler, they do not tell the entire story.