This is the mail archive of the 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.

This sounds like saying that you don't care about the standard. (Moreover, INT_MIN % -1 is no more a special case than 5 * 3.) I very strongly disagree with this view: standard compliance and correctness are far more important than speed. I believe the default behavior of GCC (of any serious C/C++ compiler, for that matter) should be to do the right thing. For those that care more about speed than safety or that are willing to program in a language that is not C/C++, something like the -ffast-math option can be provided.

Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy

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