all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#5754: Bytecomp Arithmetic test failed
@ 2010-03-23  7:47 Juri Linkov
  2010-03-23  8:38 ` Lennart Borgman
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Juri Linkov @ 2010-03-23  7:47 UTC (permalink / raw)
  To: 5754

I tried to run some tests in the `test' subdir,
and `bytecomp-testsuite-run' in `test/bytecomp-testsuite.el' fails
on one test: (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
returns 5e-324 when evaluated by interpreter,
but after byte-compilation returns 0.0

In GNU Emacs 24.0.50 (x86_64-pc-linux-gnu) of 2010-03-23
Windowing system distributor `The X.Org Foundation', version 11.0.10400090
configured using `configure  '--with-x-toolkit=no'
'CFLAGS=-g3 -O0 -Wno-pointer-sign -fno-inline -fno-crossjumping''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: en_DK.utf8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=SCIM
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

-- 
Juri Linkov
http://www.jurta.org/emacs/







^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23  7:47 bug#5754: Bytecomp Arithmetic test failed Juri Linkov
@ 2010-03-23  8:38 ` Lennart Borgman
  2010-03-23  9:03   ` Juri Linkov
  2010-03-25  7:19 ` Juri Linkov
  2010-04-03 22:40 ` Chong Yidong
  2 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2010-03-23  8:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 5754

On Tue, Mar 23, 2010 at 8:47 AM, Juri Linkov <juri@jurta.org> wrote:
> I tried to run some tests in the `test' subdir,

Should not these tests be run automatically when building Emacs?

> and `bytecomp-testsuite-run' in `test/bytecomp-testsuite.el' fails
> on one test: (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
> returns 5e-324 when evaluated by interpreter,
> but after byte-compilation returns 0.0






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23  8:38 ` Lennart Borgman
@ 2010-03-23  9:03   ` Juri Linkov
  2010-03-23 13:31     ` Lennart Borgman
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2010-03-23  9:03 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: 5754

>> I tried to run some tests in the `test' subdir,
>
> Should not these tests be run automatically when building Emacs?

Not when building Emacs, but there should be a make target like
`make test'.  And when choosing a unit test framework to add to Emacs,
the main criteria should be the ability to run tests in batch mode.

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23  9:03   ` Juri Linkov
@ 2010-03-23 13:31     ` Lennart Borgman
  2010-03-24 22:15       ` Chong Yidong
  0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2010-03-23 13:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 5754

On Tue, Mar 23, 2010 at 10:03 AM, Juri Linkov <juri@jurta.org> wrote:
>>> I tried to run some tests in the `test' subdir,
>>
>> Should not these tests be run automatically when building Emacs?
>
> Not when building Emacs, but there should be a make target like
> `make test'.  And when choosing a unit test framework to add to Emacs,
> the main criteria should be the ability to run tests in batch mode.


(Sorry for taking up the question here, but I hope it is not forgotten.)

Yes, there should such a target. But why don't you think it would be
run at the end of the build process?






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23 13:31     ` Lennart Borgman
@ 2010-03-24 22:15       ` Chong Yidong
  2010-03-24 22:52         ` Lennart Borgman
  0 siblings, 1 reply; 16+ messages in thread
From: Chong Yidong @ 2010-03-24 22:15 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: 5754

Lennart Borgman <lennart.borgman@gmail.com> writes:

>> Not when building Emacs, but there should be a make target like
>> `make test'.  And when choosing a unit test framework to add to Emacs,
>> the main criteria should be the ability to run tests in batch mode.
>
> Yes, there should such a target. But why don't you think it would be
> run at the end of the build process?

No, thanks.  It would be a nuisance for developers.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-24 22:15       ` Chong Yidong
@ 2010-03-24 22:52         ` Lennart Borgman
  2010-03-25  1:15           ` Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2010-03-24 22:52 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5754

On Wed, Mar 24, 2010 at 11:15 PM, Chong Yidong <cyd@stupidchicken.com> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> writes:
>
>>> Not when building Emacs, but there should be a make target like
>>> `make test'.  And when choosing a unit test framework to add to Emacs,
>>> the main criteria should be the ability to run tests in batch mode.
>>
>> Yes, there should such a target. But why don't you think it would be
>> run at the end of the build process?
>
> No, thanks.  It would be a nuisance for developers.


In what way?

The idea behind unit tests is to catch errors as soon as possible
after each change. Would not running the unit tests directly after
building help with that? Some problems are platform specific and will
perhaps show up during unit tests.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-24 22:52         ` Lennart Borgman
@ 2010-03-25  1:15           ` Stefan Monnier
  2010-03-25  1:19             ` Lennart Borgman
  0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2010-03-25  1:15 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Chong Yidong, 5754

>>>> Not when building Emacs, but there should be a make target like
>>>> `make test'.  And when choosing a unit test framework to add to Emacs,
>>>> the main criteria should be the ability to run tests in batch mode.
>>> Yes, there should such a target. But why don't you think it would be
>>> run at the end of the build process?
>> No, thanks.  It would be a nuisance for developers.
> In what way?
> The idea behind unit tests is to catch errors as soon as possible
> after each change. Would not running the unit tests directly after
> building help with that? Some problems are platform specific and will
> perhaps show up during unit tests.

It could only work if running the test takes a negligible amount of
time, and it generates almost no output if all goes well.
The second point is probably easy, but the first is unlikely to stay
true for long.


        Stefan






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-25  1:15           ` Stefan Monnier
@ 2010-03-25  1:19             ` Lennart Borgman
  0 siblings, 0 replies; 16+ messages in thread
From: Lennart Borgman @ 2010-03-25  1:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Chong Yidong, 5754

On Thu, Mar 25, 2010 at 2:15 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>>>> Not when building Emacs, but there should be a make target like
>>>>> `make test'.  And when choosing a unit test framework to add to Emacs,
>>>>> the main criteria should be the ability to run tests in batch mode.
>>>> Yes, there should such a target. But why don't you think it would be
>>>> run at the end of the build process?
>>> No, thanks.  It would be a nuisance for developers.
>> In what way?
>> The idea behind unit tests is to catch errors as soon as possible
>> after each change. Would not running the unit tests directly after
>> building help with that? Some problems are platform specific and will
>> perhaps show up during unit tests.
>
> It could only work if running the test takes a negligible amount of
> time, and it generates almost no output if all goes well.

Or if fail is noticeable.

> The second point is probably easy, but the first is unlikely to stay
> true for long.

Why not try it and remove it if it becomes a burden?






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23  7:47 bug#5754: Bytecomp Arithmetic test failed Juri Linkov
  2010-03-23  8:38 ` Lennart Borgman
@ 2010-03-25  7:19 ` Juri Linkov
  2010-03-30 16:08   ` Juri Linkov
  2010-04-03 22:18   ` Juri Linkov
  2010-04-03 22:40 ` Chong Yidong
  2 siblings, 2 replies; 16+ messages in thread
From: Juri Linkov @ 2010-03-25  7:19 UTC (permalink / raw)
  To: 5754

> I tried to run some tests in the `test' subdir,
> and `bytecomp-testsuite-run' in `test/bytecomp-testsuite.el' fails
> on one test: (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
> returns 5e-324 when evaluated by interpreter,
> but after byte-compilation returns 0.0

This bug is caused by optimization in byte-compilation
that changes the order of function arguments.

It byte-compiles

  (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))

to

0	constant  expt
1	constant  2
2	constant  -1074
3	call	  2
4	constant  0.125
5	varbind	  b
6	varbind	  a
7	constant  *
8	varref	  a
9	varref	  b
10	constant  8
11	call	  3
12	unbind	  2
13	return

where the order of arguments 8-10 is changed from (* a 8 b) to (* a b 8)

For this test the different order of arguments changes
the returned value:

(funcall '* 5e-324 8 0.125)
=> 5e-324

(funcall '* 5e-324 0.125 8)
=> 0.0

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-25  7:19 ` Juri Linkov
@ 2010-03-30 16:08   ` Juri Linkov
  2010-04-03 22:18   ` Juri Linkov
  1 sibling, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2010-03-30 16:08 UTC (permalink / raw)
  To: 5754; +Cc: Shigeru Fukaya

I see that this was extensively discussed in bug#1334,
so I Cc:ed Shigeru Fukaya.  Shigeru, are you interested in
looking at the test failure reported by bytecomp-testsuite.el?

>> I tried to run some tests in the `test' subdir,
>> and `bytecomp-testsuite-run' in `test/bytecomp-testsuite.el' fails
>> on one test: (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
>> returns 5e-324 when evaluated by interpreter,
>> but after byte-compilation returns 0.0
>>
>> In GNU Emacs 24.0.50 (x86_64-pc-linux-gnu) of 2010-03-23
>
> This bug is caused by optimization in byte-compilation
> that changes the order of function arguments.
>
> It byte-compiles
>
>   (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
>
> to
>
> 0	constant  expt
> 1	constant  2
> 2	constant  -1074
> 3	call	  2
> 4	constant  0.125
> 5	varbind	  b
> 6	varbind	  a
> 7	constant  *
> 8	varref	  a
> 9	varref	  b
> 10	constant  8
> 11	call	  3
> 12	unbind	  2
> 13	return
>
> where the order of arguments 8-10 is changed from (* a 8 b) to (* a b 8)
>
> For this test the different order of arguments changes
> the returned value:
>
> (funcall '* 5e-324 8 0.125)
> => 5e-324
>
> (funcall '* 5e-324 0.125 8)
> => 0.0

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-25  7:19 ` Juri Linkov
  2010-03-30 16:08   ` Juri Linkov
@ 2010-04-03 22:18   ` Juri Linkov
  1 sibling, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2010-04-03 22:18 UTC (permalink / raw)
  To: 5754

> For this test the different order of arguments changes
> the returned value:
>
> (funcall '* 5e-324 8 0.125)
> => 5e-324
>
> (funcall '* 5e-324 0.125 8)
> => 0.0

`byte-optimize-plus' and `byte-optimize-minus' avoid this problem
by not using `byte-optimize-delay-constants-math' (see how its call
is commented out in `byte-opt.el').  Maybe `byte-optimize-multiply'
and `byte-optimize-divide' should do the same?

=== modified file 'lisp/emacs-lisp/byte-opt.el'
--- lisp/emacs-lisp/byte-opt.el	2010-01-13 08:35:10 +0000
+++ lisp/emacs-lisp/byte-opt.el	2010-04-03 22:16:20 +0000
@@ -806,7 +806,8 @@ (defun byte-optimize-minus (form)
   (byte-optimize-predicate form))
 
 (defun byte-optimize-multiply (form)
-  (setq form (byte-optimize-delay-constants-math form 1 '*))
+  ;; Don't call `byte-optimize-delay-constants-math' (bug#1334, bug#5754).
+  ;; (setq form (byte-optimize-delay-constants-math form 1 '*))
   ;; For (* constants..), byte-optimize-predicate does the work.
   (when (memq nil (mapcar 'numberp (cdr form)))
     ;; After `byte-optimize-predicate', if there is a INTEGER constant
@@ -823,7 +824,8 @@ (defun byte-optimize-multiply (form)
   (byte-optimize-predicate form))
 
 (defun byte-optimize-divide (form)
-  (setq form (byte-optimize-delay-constants-math form 2 '*))
+  ;; Don't call `byte-optimize-delay-constants-math' (bug#1334, bug#5754).
+  ;; (setq form (byte-optimize-delay-constants-math form 2 '*))
   ;; After `byte-optimize-predicate', if there is a INTEGER constant
   ;; in FORM, it is in the last element.
   (let ((last (car (reverse (cdr (cdr form))))))

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-03-23  7:47 bug#5754: Bytecomp Arithmetic test failed Juri Linkov
  2010-03-23  8:38 ` Lennart Borgman
  2010-03-25  7:19 ` Juri Linkov
@ 2010-04-03 22:40 ` Chong Yidong
  2010-04-03 22:54   ` Juri Linkov
                     ` (2 more replies)
  2 siblings, 3 replies; 16+ messages in thread
From: Chong Yidong @ 2010-04-03 22:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 5754

> I tried to run some tests in the `test' subdir,
> and `bytecomp-testsuite-run' in `test/bytecomp-testsuite.el' fails
> on one test: (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
> returns 5e-324 when evaluated by interpreter,
> but after byte-compilation returns 0.0

I originally thought this was a regression, because my copy of Emacs
23.1 did not appear to have this problem.  On further investigation, it
is not a regression.  Emacs 23.1 and before also have the problem.

The key is that if I compile Emacs with CFLAGS="-g", then

(funcall
 (byte-compile
  (list 'lambda nil
	(quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))

returns 0.0.  If I compile Emacs with CFLAGS="-g -O2", then it returns
5e-324.

It looks like this may be a compiler bug.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-04-03 22:40 ` Chong Yidong
@ 2010-04-03 22:54   ` Juri Linkov
  2010-04-03 23:31     ` Chong Yidong
  2010-04-04  6:25   ` Eli Zaretskii
  2010-04-04  8:05   ` Andreas Schwab
  2 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2010-04-03 22:54 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5754

> I originally thought this was a regression, because my copy of Emacs
> 23.1 did not appear to have this problem.  On further investigation, it
> is not a regression.  Emacs 23.1 and before also have the problem.
>
> The key is that if I compile Emacs with CFLAGS="-g", then
>
> (funcall
>  (byte-compile
>   (list 'lambda nil
> 	(quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))
>
> returns 0.0.  If I compile Emacs with CFLAGS="-g -O2", then it returns
> 5e-324.

Does (let ((a (expt 2 -1074)) (b 0.125)) (* a b 8))
return 5e-324 when you compile with CFLAGS="-g -O2"?

Note the constant 8 at the end, this form is what actually
executed after byte-compilation with optimization.

I guess if

(funcall
 (byte-compile
  (list 'lambda nil
	(quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))

returns 5e-324 with CFLAGS="-g -O2",
then

(let ((a (expt 2 -1074)) (b 0.125)) (* a b 8))

returns 5e-324 as well?

-- 
Juri Linkov
http://www.jurta.org/emacs/






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-04-03 22:54   ` Juri Linkov
@ 2010-04-03 23:31     ` Chong Yidong
  0 siblings, 0 replies; 16+ messages in thread
From: Chong Yidong @ 2010-04-03 23:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 5754

Juri Linkov <juri@jurta.org> writes:

> Does (let ((a (expt 2 -1074)) (b 0.125)) (* a b 8))
> return 5e-324 when you compile with CFLAGS="-g -O2"?

With CFLAGS="-g -O2",

  (let ((a (expt 2 -1074)) (b 0.125)) (* a b 8))
     => 5e-24

  (eval '(let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b)))
     => 5e-324

  (funcall (byte-compile
    (list 'lambda nil
      (quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))
     => 5e-24

With CFLAGS="-g",

  (let ((a (expt 2 -1074)) (b 0.125)) (* a b 8))
     => 0.0

  (eval '(let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b)))
     => 5e-324

  (funcall (byte-compile
    (list 'lambda nil
      (quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))
     => 0.0

The latter two are what cause bytecomp-testsuite to fail.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-04-03 22:40 ` Chong Yidong
  2010-04-03 22:54   ` Juri Linkov
@ 2010-04-04  6:25   ` Eli Zaretskii
  2010-04-04  8:05   ` Andreas Schwab
  2 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2010-04-04  6:25 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5754

> From: Chong Yidong <cyd@stupidchicken.com>
> Date: Sat, 03 Apr 2010 18:40:59 -0400
> Cc: 5754@debbugs.gnu.org
> 
> The key is that if I compile Emacs with CFLAGS="-g", then
> 
> (funcall
>  (byte-compile
>   (list 'lambda nil
> 	(quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))
> 
> returns 0.0.  If I compile Emacs with CFLAGS="-g -O2", then it returns
> 5e-324.
> 
> It looks like this may be a compiler bug.

I doubt it.  I see this in GCC 3.4.x; the chances that two very
different versions have the same bug are less than slim, I think.

I'd suspect some bug in our code, before considering a GCC bug.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#5754: Bytecomp Arithmetic test failed
  2010-04-03 22:40 ` Chong Yidong
  2010-04-03 22:54   ` Juri Linkov
  2010-04-04  6:25   ` Eli Zaretskii
@ 2010-04-04  8:05   ` Andreas Schwab
  2 siblings, 0 replies; 16+ messages in thread
From: Andreas Schwab @ 2010-04-04  8:05 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 5754

Chong Yidong <cyd@stupidchicken.com> writes:

> The key is that if I compile Emacs with CFLAGS="-g", then
>
> (funcall
>  (byte-compile
>   (list 'lambda nil
> 	(quote (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))))))
>
> returns 0.0.  If I compile Emacs with CFLAGS="-g -O2", then it returns
> 5e-324.
>
> It looks like this may be a compiler bug.

It's most likely the effect of excess precision, due to floating point
values being held in registers instead of reloaded from memory.  Try
-ffloat-store.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."






^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-04-04  8:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23  7:47 bug#5754: Bytecomp Arithmetic test failed Juri Linkov
2010-03-23  8:38 ` Lennart Borgman
2010-03-23  9:03   ` Juri Linkov
2010-03-23 13:31     ` Lennart Borgman
2010-03-24 22:15       ` Chong Yidong
2010-03-24 22:52         ` Lennart Borgman
2010-03-25  1:15           ` Stefan Monnier
2010-03-25  1:19             ` Lennart Borgman
2010-03-25  7:19 ` Juri Linkov
2010-03-30 16:08   ` Juri Linkov
2010-04-03 22:18   ` Juri Linkov
2010-04-03 22:40 ` Chong Yidong
2010-04-03 22:54   ` Juri Linkov
2010-04-03 23:31     ` Chong Yidong
2010-04-04  6:25   ` Eli Zaretskii
2010-04-04  8:05   ` Andreas Schwab

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.