Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

div by zero folding deferred to run-time

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


ikegami at adaelis

May 16, 2008, 7:57 AM

Post #1 of 2 (89 views)
Permalink
div by zero folding deferred to run-time

Hello,
Division by zero exceptions that occur during constant folding are
being deferred to run-time. Is that intentional or is that a
regression?
Eric Brine


** 5.8.8, Exception during constant folding: **

>c:\progs\perl588\bin\perl -MO=Concise -e"1/0"
Illegal division by zero at -e line 1.


** 5.10.0, Exception deferred to run-time: **

>c:\progs\perl5100\bin\perl -MO=Concise -e"1/0"

6 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
5 <2> divide[t1] vK/2 ->6
3 <$> const[PVNV 1] s ->4
4 <$> const[PVNV 0] s ->5
-e syntax OK

>c:\progs\perl5100\bin\perl -e"1/0"
Illegal division by zero at -e line 1.


** 5.10.0 still folds other constants: **

>c:\progs\perl5100\bin\perl -MO=Concise -e"1/2"

3 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
- <0> ex-const v ->3
-e syntax OK


This is perl, v5.8.8 built for MSWin32-x86-multi-thread
Binary build 817 [257965] provided by ActiveState

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
Binary build 1001 [283495] provided by ActiveState


nick at ccl4

May 16, 2008, 12:00 PM

Post #2 of 2 (80 views)
Permalink
Re: div by zero folding deferred to run-time [In reply to]

On Fri, May 16, 2008 at 10:57:35AM -0400, Eric Brine wrote:
> Hello,
> Division by zero exceptions that occur during constant folding are
> being deferred to run-time. Is that intentional or is that a
> regression?

It's intentional. Constant folding is an optimisation, and optimisations
shouldn't make a difference to the execution of the program.

Compile time exceptions (or warnings - fixed that too) violate that. It means
that division by zero in code that will never be executed can now be compiled
at all. For example, anything that defines constants that on some platforms
happen to be zero, but that code isn't run on those platforms. Effectively,
anything that reduces to


$ ./perl -Ilib -le 'use constant A => 0;' -e 'print 4/A if A; print $]; print A'
5.011000
0

Nicholas Clark

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.