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


Andrew Haley wrote:
Roberto Bagnara writes:
> > Reading the thread "Autoconf manual's coverage of signed integer
> overflow & portability" I was horrified to discover about GCC's
> miscompilation of the remainder expression that causes INT_MIN % -1
> to cause a SIGFPE on CPUs of the i386 family. Are there plans to
> fix this bug (which, to me, looks quite serious)?


No, there aren't.  It would make more sense for you to wrap % in some
code that checks for this, rather than for us to slow down every division
for this one special case.

With all due respect, I must say I am shocked. I always thought (and taught) that we, Free Software people, value standard conformance and getting things right. Now we have a bug that can shut down airplanes and dealing with it is (in extreme synthesis) assimilated to nitpicking. I have not found a mention of this bug in the "Known Bugs" section of http://gcc.gnu.org: perhaps I missed it, but I think it definitely should be brought to the attention of the users since, IMHO, no one really expects a remainder expression to cause a SIGFPE. I have also looked at the bug database, and I did not find any report concerning this bug, so I created one:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30484

A final remark: I think that today the problem is safety, not speed.
I don't think doing the right thing for remainder expression will
have such a high cost with the help of the optimizer and, maybe,
assistance from the kernel.  But even if the cost turns out to be high,
the actual state of things is unacceptable: mentioning the bug prominently
in the documentation, trying to change the standard, ..., whatever;
but not leaving things as they are.
All the best,

Roberto

--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it


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