* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
@ 2014-06-03 19:12 David Engster
2014-06-05 22:26 ` Glenn Morris
2016-06-26 4:53 ` Noam Postavsky
0 siblings, 2 replies; 8+ messages in thread
From: David Engster @ 2014-06-03 19:12 UTC (permalink / raw)
To: 17681
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.
-David
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-03 19:12 bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators David Engster
@ 2014-06-05 22:26 ` Glenn Morris
2014-06-06 1:04 ` Stefan Monnier
2016-06-26 4:53 ` Noam Postavsky
1 sibling, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2014-06-05 22:26 UTC (permalink / raw)
To: luke.yx.lee; +Cc: 17681, David Engster
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-05 22:26 ` Glenn Morris
@ 2014-06-06 1:04 ` Stefan Monnier
2014-06-06 6:00 ` Luke Lee
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2014-06-06 1:04 UTC (permalink / raw)
To: Glenn Morris; +Cc: luke.yx.lee, 17681, David Engster
> 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
I think he already sent me a patch fixing this problem (which IIUC is
a problem I introduced, BTW).
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-06 1:04 ` Stefan Monnier
@ 2014-06-06 6:00 ` Luke Lee
2014-06-06 7:17 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Luke Lee @ 2014-06-06 6:00 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 17681, David Engster
[-- Attachment #1: Type: text/plain, Size: 762 bytes --]
>I think he already sent me a patch fixing this problem
Yes, I think my new patch fixed that problem. However, if you're trying to
hide
jiffies.h it will eventually failed at some other place due to the
"unsigned long"
integer postfix (i.e. the "UL" in 100000UL), which hideif still consider it
a "TODO".
#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
2014-06-06 9:04 GMT+08:00 Stefan Monnier <monnier@iro.umontreal.ca>:
> > 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
>
> I think he already sent me a patch fixing this problem (which IIUC is
> a problem I introduced, BTW).
>
>
> Stefan
>
--
Best regards,
Luke Lee
[-- Attachment #2: Type: text/html, Size: 1408 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-06 6:00 ` Luke Lee
@ 2014-06-06 7:17 ` Glenn Morris
2014-06-06 11:11 ` Luke Lee
0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2014-06-06 7:17 UTC (permalink / raw)
To: Luke Lee; +Cc: 17681, David Engster
Luke Lee wrote:
>>I think he already sent me a patch fixing this problem
>
> Yes, I think my new patch fixed that problem.
Is this patch posted anywhere?
> However, if you're trying to hide jiffies.h it will eventually failed
> at some other place due to the "unsigned long" integer postfix (i.e.
> the "UL" in 100000UL), which hideif still consider it a "TODO".
>
> #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
When you say fail, do you mean it will give an error?
If so, why not ignore-errors around these evaluations?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-06 7:17 ` Glenn Morris
@ 2014-06-06 11:11 ` Luke Lee
2014-06-06 15:19 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Luke Lee @ 2014-06-06 11:11 UTC (permalink / raw)
To: Glenn Morris; +Cc: 17681, David Engster
[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]
>Is this patch posted anywhere?
I only send it to Stefan for review since it's a set of patches
that forms the complete work of
http://www.emacswiki.org/emacs/hideif.el.
Patch set #1 has already been submitted into Emacs trunk
while patch set #2 is still under Stefan's reviewing. Patchset
#3 to come. All 3 patches forms the hideif.el posted on
EmacsWiki. You can try this version.
>When you say fail, do you mean it will give an error?
>If so, why not ignore-errors around these evaluations?
Different versions of Emacs seems to behave
differently. On my Linux machine it's Emacs 24.3.50.2
and it does not throw any error. On Cygwin Emacs
24.3.2 it throw an error. It seems that others' submitted
`hif-string-to-number' introduced some difference.
On Cygwin's Emacs version the `split-string' function
used in `hif-string-to-number' take no more than 3
arguments but it takes 4 arguments in my Linux
Emacs 24.3.50.2. After fixing this they still behave
differently. I'm focusing on Linux version so I did
not investigate what makes the difference.
Due to the internal behavior of hideif sometimes it's
not so easy to just ignore some errors then continue.
There are still some cases that hideif will throw an
error. To prevent hideif from throwing any errors, it's
actually another TODO item. I'll first complete the
reviewing of the remaining patch set.
2014-06-06 15:17 GMT+08:00 Glenn Morris <rgm@gnu.org>:
> Luke Lee wrote:
>
> >>I think he already sent me a patch fixing this problem
> >
> > Yes, I think my new patch fixed that problem.
>
> Is this patch posted anywhere?
>
> > However, if you're trying to hide jiffies.h it will eventually failed
> > at some other place due to the "unsigned long" integer postfix (i.e.
> > the "UL" in 100000UL), which hideif still consider it a "TODO".
> >
> > #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
>
> When you say fail, do you mean it will give an error?
> If so, why not ignore-errors around these evaluations?
>
--
Best regards,
Luke Lee
[-- Attachment #2: Type: text/html, Size: 2955 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-06 11:11 ` Luke Lee
@ 2014-06-06 15:19 ` Glenn Morris
0 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2014-06-06 15:19 UTC (permalink / raw)
To: Luke Lee; +Cc: 17681, David Engster
Luke Lee wrote:
> Different versions of Emacs seems to behave differently. On my Linux
> machine it's Emacs 24.3.50.2 and it does not throw any error. On
> Cygwin Emacs 24.3.2 it throw an error.
The relevant version at the moment is the Emacs 24.3.91 pretest.
http://alpha.gnu.org/gnu/emacs/pretest/emacs-24.3.91.tar.xz
24.3.50 is an old development version and should not be used any more.
> It seems that others' submitted `hif-string-to-number' introduced some
> difference.
Apart from your 2014-01-28 changes, I see no changes to hideif.el in
Emacs 24.3.91 since 2012-10-02. hif-string-to-number is only in the
Emacs trunk, not the emacs-24 branch, so doesn't affect this report.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
2014-06-03 19:12 bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators David Engster
2014-06-05 22:26 ` Glenn Morris
@ 2016-06-26 4:53 ` Noam Postavsky
1 sibling, 0 replies; 8+ messages in thread
From: Noam Postavsky @ 2016-06-26 4:53 UTC (permalink / raw)
To: 17681-done
Version: 25.0.95
I see the problem in Emacs 24.5, but not Emacs 25.0.95, so it seems to
have been fixed sometime in between.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-06-26 4:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-03 19:12 bug#17681: 24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators David Engster
2014-06-05 22:26 ` Glenn Morris
2014-06-06 1:04 ` Stefan Monnier
2014-06-06 6:00 ` Luke Lee
2014-06-06 7:17 ` Glenn Morris
2014-06-06 11:11 ` Luke Lee
2014-06-06 15:19 ` Glenn Morris
2016-06-26 4:53 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.