This is the mail archive of the gcc@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]

Re: Miscompilation of remainder expressions


David Daney wrote:
Roberto Bagnara wrote:

Everyone knows that dividing a number by -1 or 1 gives a 0 remainder. To the contrary, no one expects a%b to raise SIFPE when b != 0.


On the contrary, since the beginning of time SIGFPE has been generated on GCC/x86/linux under these conditions. This is wildly known.


Just because you just found out about it does not mean that 'no one' expects it.

Indeed, I would never write this expression expecting the result to be reliably zero, since x86 chips have treated this as a divide by zero since the beginning of time (well 1981 :-)), a SIGFPE is quite expected! So I guess Roberto's "no one" does not include me :-)

David Daney


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