D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5689 - [64-Bit] uniform() fails with -profile
Summary: [64-Bit] uniform() fails with -profile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2011-03-03 01:04 UTC by Trass3r
Modified: 2012-04-20 20:40 UTC (History)
2 users (show)

See Also:


Attachments
Disassembly from objdump (883.97 KB, application/octet-stream)
2012-03-15 20:17 UTC, James Miller
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Trass3r 2011-03-03 01:04:42 UTC
import std.random;

void main()
{
    auto f = uniform(0.0, 1.0);
}

$ dmd -m64 -profile profile.d
$ ./profile 
object.Exception@dmd/linux/bin/../../src/phobos/std/random.d(932): Invalid distribution range: [0, 0)
----------------

Compiling it without -profile or m64 works.
Comment 1 Trass3r 2011-08-07 17:37:49 UTC
Another case:

import std.random;
void main()
{
	double r1=2*uniform(0.0, 1.0);
	double r2=2*uniform(0.0, 1.0);
}

It only fails if both declarations are present.

invalid bounding interval [7.69602e+169, -nan)

btw, if -inline is added, it yields:
invalid bounding interval [7.29112e-304, 1.12477e+218)
Comment 2 Martin Nowak 2012-03-15 13:52:38 UTC
I can't reproduce this.
What are your compiler version and parameters.
Comment 3 Trass3r 2012-03-15 14:03:28 UTC
With git dmd on Ubuntu 11.04 it's now:
$ dmd -m64 -profile test.d
$ ./test 
object.Exception@std/random.d(940): std.random.uniform(): invalid bounding interval [1.42645e+242, 1.62687e+219)
Comment 4 James Miller 2012-03-15 20:14:01 UTC
Floating point causes incorrect values, no errors, reduced down to this code:

import std.random : uniform;

void main() {
    uniform(0.0f, 1.0f);
}

uniform returns values around 1.4203e+31
Comment 5 James Miller 2012-03-15 20:17:22 UTC
Created attachment 1081 [details]
Disassembly from objdump
Comment 7 github-bugzilla 2012-03-21 00:04:58 UTC
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/c7dc74a32ea823a86304bb874e7308309dce6f37
Merge pull request #180 from dawgfoto/fix5689

fix issue 5689
Comment 8 github-bugzilla 2012-04-20 20:40:17 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a2e777e0c8d8a474ea04fb5d3ef1748638f4e1aa
test case for druntime Bug 5689

https://github.com/D-Programming-Language/dmd/commit/6905b385eb70540193f7d890ef48f216c7bc1086
Merge pull request #820 from dawgfoto/fix5689

test case for druntime Bug 5689