This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Inexact-Result (Precision) Exception (#P)


I have some code that's built with gcc that has been working for a long
time.  Now I'm getting floating point exceptions from this:

Program received signal SIGFPE, Arithmetic exception.
0x000000000042cb86 in toCycles (picos=17) at ../src/sigfpe.hh:12
12      return picos / picosPerTick() + 0.5;
1: x/3i $pc
0x42cb86 <_Z8toCyclesm+89>:    cvttsd2si %xmm0,%rax
(gdb) info registers
rax            0x1    1
mxcsr          0x20    [ PE ]

You can see the PE bit is pulled up.

>From Intel's manual:
11.5.2.6
Inexact-Result (Precision) Exception (#P)
The inexact-result exception (also called the precision exception)
occurs if the result
of an operation is not exactly representable in the destination format.
For example,
the fraction 1/3 cannot be precisely represented in binary form. This
exception
occurs frequently and indicates that some (normally acceptable) accuracy
has been
lost. The exception is supported for applications that need to perform
exact arith-
metic only. Because the rounded result is generally satisfactory for
most applica-
tions, this exception is commonly masked.
The flag (PE) and mask (PM) bits for the inexact-result exception are
bits 2 and 12,
respectively, in the MXCSR register.

I'm assuming from that this is normally masked but now it's not.  What
could have changed that would
cause this?  How do I get gcc to have the PM bit pulled up?

Patrick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]