www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8369] New: try/finally block and float division by zero

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8369

           Summary: try/finally block and float division by zero
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: lomereiter gmail.com



PDT ---
The following code segfaults when I run it with "rdmd bug.d 0":

import std.stdio, std.conv;

float a, b = 0.0;
void main(string[] args) {
    try {
        a = to!float(args[1]);
    } finally {
        writeln(a / b); 
    }   
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 10 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8369


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com



PST ---
http://dpaste.dzfl.pl/f48bd90a

This one gave me some surprising results on DPaste. The results are
inconsistent from run to run.

A few times, I got

Application output:
a/b = nan
Application error:
core.exception.RangeError /home/c891/c322.d(6): Range violation

But most of the times, I get a "successful" run without any output.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 31 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8369


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---
First of all, it does not segfault on 2.061.


 http://dpaste.dzfl.pl/f48bd90a
 
 This one gave me some surprising results on DPaste. The results are
 inconsistent from run to run.
 
 A few times, I got
 
 Application output:
 a/b = nan
 Application error:
 core.exception.RangeError /home/c891/c322.d(6): Range violation
 
 But most of the times, I get a "successful" run without any output.
Are you sure you receive no output? It seems for me the code works as expected. If you provide no args, you will have array bounds exception (what actually happens). Additionally a is defaulted to nan, so the program will also print nan in this case. If you provide some float as a program argument, you will receive inf, -inf or nan depending on the argument. So, I don't see any problem here. I checked 2.061 on win64. If on other platform it does not work properly, please provide source and specify platform. Otherwise this issue can be closed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8369


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



---
Works on linux too. Closed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2013