Ken Brody <
kenb...@spamcop.net> wrote:
> On 4/19/2013 11:58 AM, Eric Sosman wrote:
>> On 4/19/2013 11:34 AM, Johannes Bauer wrote:
>>> On 19.04.2013 17:26, Eric Sosman wrote:
>>>> It seems to me your question is just a special case of "Why
>>>> does code have bugs?"
>>> Not really -- with normal bugs, you don't "fix" the compiler, you fix
>>> the buggy code. Not in this case:
>>>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265
>>> Basically "fixes" the compiler to not optimize. This blows my mind.
Well, at the higher optimization levels it is not unusual for there
to be cases where the optimization shouldn't be done, but the compiler
has a difficult time detecting those cases.
A popular optimization is to move invariant expressions out of loops,
assuming that the expression will be executed a large number of times.
It is not always possible to decide if the move is safe.
>> Sorry for misunderstanding the thrust of your question. As
>> to why the GCC folks chose to kludge the compiler to let the buggy
>> code slide by, it seems more of a "marketing" decision than a
>> technical one. The new compiler exposed bugs that had (apparently)
> [...]
> Consider, for example, when the IBM-PC was first introduced, there were bugs
> in the BIOS. Clones, for the sake of "100% compatibility", purposely
> included those same bugs in their BIOS, lest some program fail to run
> because it depended on the buggy behavior.
Q: What is the difference between a bug and a feature?
A: A feature is documented.
Since the BIOS commented assembly code was published (and copyrighted)
it was well documented. Still, some of the features were less useful
than they might have been.
There have been a number of cases where new hardware (or emulation in
hardware or software) had to implement bugs in the original, or failed
due to lack of such.
Some stories I remember had to do with incompatibilities between the
8080, Z80, and NEC V20 in 8080 emulation mode. Some I believe had to
do with flag bits that were left undefined in the 8080, but that some
programs (especially the early MS BASIC) depended on the undocumented
implementation on the 8080.
In the case of the IBM PC, many programs didn't use the BIOS calls, but
went directly to hardware, mostly for speed reasons. Microsoft Flight
Simulator was the favorite test case for clone hardware. So, not only do
you have to implement the BIOS bugs, but the hardware bugs as well.
The 20 bit address space of the 8088, would wrap when the
segment<<4+offset was too big, but on the 80286 and later, with a 24
bit address bus, would not wrap. Hardware was added to 80286 and later
machines to zero address bit 20 when running in the appropriate mode.
Certainly seems to me a bug for software to depend on address wrapping,
but a hardware fix was needed.
-- glen