Subject: Re: bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators

From: Glenn Morris <[email-masked]>
Date: Thu, 05 Jun 2014 18:26:15 -0400

Luke, could you take a look at this report please?

http://debbugs.gnu.org/17681

An artificial but smaller example might be:

#if 1 / FOO
#endif

David Engster wrote:

> Recipe:
>
> - Create a file "test.h" containing the following (this is from
>   the file 'jiffies.h' in the Linux kernel):
>
> #if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
> #endif
>
> - emacs -Q
>
> - Load the file, activate hide-ifdef-mode
>
> - C-c @ h  (hide-ifdefs)
>
> The minibuffer will show "Arithmetic Error". Here is the backtrace:
>
> Debugger entered--Lisp error: (arith-error)
>   hif-divide(0 nil)
>   (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2))
>   (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)
>   (hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0))
>   eval((hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)))
>   hif-possibly-hide()
>   hide-ifdef-guts()
>   hide-ifdefs()
>
> Earlier Emacsen did not throw an error here (although it is very
> possible that the above line wasn't calculated correctly). Still, this
> probably qualifies as a regression.