Gabriel Dos Reis writes: > Andrew Haley <[EMAIL PROTECTED]> writes: > > | Michael Veksler writes: > | > Roberto Bagnara wrote: > | > > > | > > 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)? > | > > All the best, > | > > > | > This problem is quite rare in practice (otherwise there would be > | > much more complaining). As such it may be too expensive, > | > performance-wise, to fix in GCC. It seems as one of those > | > classical things that can be worked-around in the kernel. > | > | I guess, or it can be fixed-up in user space. We already do this for > | the Java language. > > Andrew pointed me to his implementation. > I, however, have a question: why do we need to mess with signals at all? > I mean, could not we generate the following for "%": > > rem a b := > if abs(b) == 1 > return 0 > return <machine-instruction> a b > > is there any other corner case that will trigger the trap?
I have tried it, and it is pretty expensive. It messes up the pipelines and it hides the % from the optimizer. IMO we should not do this by default, since it's such a nitpicky corner case. Andrew.