Subject: bug#5754: Bytecomp Arithmetic test failed

From: Juri Linkov <[email-masked]>
Date: Tue, 30 Mar 2010 19:08:45 +0300

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/