Board index » cppbuilder » Spurious floating point exceptions in IDE/de{*word*81}

Spurious floating point exceptions in IDE/de{*word*81}

Hello all;
BCB4  AMD 450M processor, 128M RAM. The following strange behaviour of the
Integrated De{*word*81}/IDE is independent of whether or not the patches are
applied. Has anyone else come across this and can supply or direct me to an
explanation and, hopefully, workround?

I have only recently installed BCB4 and have moved a project from BCB3. It
is possible that work up to the last few days would not have provoked the
incident. I have reinstalled BCB4 from clean and re-built the whole program,
with no alleviation of the phenomenon. The phenonemon was not perceived in
BCB3.

I give a summary of the problem below. I have not included actual example
code as the fault can be provoked in a number of places in the program (in
different units) and does not seem dependent on any particular code
sequence.

Summary of problem :
In several places where I have a function which manipulates float variables,
generally called from an outer loop, _if_ I place a breakpoint _in_ this
function, and execution stops on this breakpoint, then on resumption it is
almost certain that an "Invalid Floating Point Operation" Exception will be
thrown. Not necessarily on the the first FP operation, but totally
consistent on which it chooses to object to and either a statement _in_ the
function itself or in a function called by it.

If the breakpoint is placed towards the end of the function, the fault is
likely to arise on re-entry to the function, i.e., before the breakpoint is
again reached.

If the breakpoint is removed (or is made conditional) the program will run
correctly and all FP operations are correctly performed (until the break
condition is reached).

Examples of statements which will _appear_ to be in error are:
  sprintf(tmp, "%9.2f", amount);  // tmp is char[20]
  TotBal += amount;   // both floats
  AnsiString FormatFloat operation

The inputs to these operations have the correct values in all cases.

If I vary the order of the FP statements in the function then the fault is
likely to occur on a different statement.

I emphasise that if the breakpoint is not placed the program works
satisfactorily.

If the breakpoint is placed at the _call_ to the function (i.e., in the
outer loop, then the fault does not occur.

I cannot see how anything in my program could cause this behaviour to occur
in different places in the program, and it seems to me that the IDE/de{*word*81}
is doing something at a breakpoint which is confusing something to do with
floating point.

Possibly related phenomenon: often, if some compiler error is reported, the
list will finish with "Illegal floating point operation" although when the
other error(s) are removed there is no such error.

Any ideas?
Derek Harvey.

 

Re:Spurious floating point exceptions in IDE/de{*word*81}


Dear Derek, I have had a similar problem sometime ago and I fixed it
resetting the coprocessor unit.
You can do it using the followong line.

_control87(MCW_EM,MCW_EM);

This is because borland and MS set the coprocessor in different ways. Maybe
the de{*word*81} calls some MS library....

Please, let me know if this fix your problem too!

-------------
ing. Luigi Bianchi
http://www.luigibianchi.com
Dfm2API : Delphi / C++ Builder Form Converter
Brain Computer Interface SDK

Quote
Derek Harvey <Derek.Har...@btinternet.com> wrote in message

news:8kirkb$8pq14@bornews.borland.com...
Quote
> Hello all;
> BCB4  AMD 450M processor, 128M RAM. The following strange behaviour of the
> Integrated De{*word*81}/IDE is independent of whether or not the patches are
> applied. Has anyone else come across this and can supply or direct me to
an
> explanation and, hopefully, workround?

Re:Spurious floating point exceptions in IDE/de{*word*81}


Thanks Luigi for the tip, but can you explain further how I should use that
line? Thanks.

Last night I downloaded a heap of MS updates to Win98; not sure yet whether
that has made any difference - there was some reference to 'libraries' in
the descriptions.

BTW, I think I forgot to say I am using Win 98. Never ran BCB4 under Win 95.
Never ran BCB3 under Win95 on this computer.
--
---------------------------------------------
Derek Harvey (Derek.Har...@btinternet.com)

Quote
Luigi Bianchi <theb...@luigibianchi.com> wrote in message

news:8kjl31$jlp1@bornews.borland.com...
Quote
> Dear Derek, I have had a similar problem sometime ago and I fixed it
> resetting the coprocessor unit.
> You can do it using the followong line.

> _control87(MCW_EM,MCW_EM);

> This is because borland and MS set the coprocessor in different ways.
Maybe
> the de{*word*81} calls some MS library....

> Please, let me know if this fix your problem too!

> -------------
> ing. Luigi Bianchi
> http://www.luigibianchi.com
> Dfm2API : Delphi / C++ Builder Form Converter
> Brain Computer Interface SDK

> Derek Harvey <Derek.Har...@btinternet.com> wrote in message
> news:8kirkb$8pq14@bornews.borland.com...
> > Hello all;
> > BCB4  AMD 450M processor, 128M RAM. The following strange behaviour of
the
> > Integrated De{*word*81}/IDE is independent of whether or not the patches are
> > applied. Has anyone else come across this and can supply or direct me to
> an
> > explanation and, hopefully, workround?

Re:Spurious floating point exceptions in IDE/de{*word*81}


The Windows Update has made no difference to the _compiler_ reporting
spurious ilegal fp operations after some other compiler-detected error, with
the fp reports going away when the other error is fixed.

Have not actually had the other breakpoint-caused error since, but haven't
done much debugging either since the update.
Derek
--
---------------------------------------------
Derek Harvey (Derek.Har...@btinternet.com)

Quote
Derek Harvey <Derek.Har...@btinternet.com> wrote in message

news:8kq7vn$iit1@bornews.borland.com...
Quote
> Thanks Luigi for the tip, but can you explain further how I should use
that
> line? Thanks.

> Last night I downloaded a heap of MS updates to Win98; not sure yet
whether
> that has made any difference - there was some reference to 'libraries' in
> the descriptions.

> BTW, I think I forgot to say I am using Win 98. Never ran BCB4 under Win
95.
> Never ran BCB3 under Win95 on this computer.
> --
> ---------------------------------------------
> Derek Harvey (Derek.Har...@btinternet.com)

> Luigi Bianchi <theb...@luigibianchi.com> wrote in message
> news:8kjl31$jlp1@bornews.borland.com...
> > Dear Derek, I have had a similar problem sometime ago and I fixed it
> > resetting the coprocessor unit.
> > You can do it using the followong line.

> > _control87(MCW_EM,MCW_EM);

> > This is because borland and MS set the coprocessor in different ways.
> Maybe
> > the de{*word*81} calls some MS library....

> > Please, let me know if this fix your problem too!

> > -------------
> > ing. Luigi Bianchi
> > http://www.luigibianchi.com
> > Dfm2API : Delphi / C++ Builder Form Converter
> > Brain Computer Interface SDK

> > Derek Harvey <Derek.Har...@btinternet.com> wrote in message
> > news:8kirkb$8pq14@bornews.borland.com...
> > > Hello all;
> > > BCB4  AMD 450M processor, 128M RAM. The following strange behaviour of
> the
> > > Integrated De{*word*81}/IDE is independent of whether or not the patches
are
> > > applied. Has anyone else come across this and can supply or direct me
to
> > an
> > > explanation and, hopefully, workround?

Other Threads