Thread overview
[Issue 5271] New: Not constant RAND_MAX
Nov 24, 2010
Walter Bright
Nov 24, 2010
Iain Buclaw
November 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5271

           Summary: Not constant RAND_MAX
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-11-24 11:42:07 PST ---
I think the std.c.stdlib.RAND_MAX (core.stdc.stdlib.RAND_MAX) value is hardcoded in Phobos, in a line of the two "stdlib.d" files:

enum RAND_MAX     = 32767;

If this is true, then it's an error, because in other systems rand() may return other values. In particular, on an Ubuntu Linux I have seen RAND_MAX needs to be int.max instead of short.max. So this value has to change according to the situation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5271


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-11-24 12:35:54 PST ---
On ubuntu it is 2147483647.

It still must be hardcoded, as it is a compile time constant, but version'd for the different platforms.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 24, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5271


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@ubuntu.com


--- Comment #2 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-11-24 13:04:50 PST ---
Having a quick look round, it is 0x7FFFFFFF on FreeBSD and OSX too. (Hexadecimal value for 2147483647).

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5271


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@kyllingen.net
          Component|Phobos                      |druntime
         AssignedTo|nobody@puremagic.com        |sean@invisibleduck.org


--- Comment #3 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2011-02-03 01:25:21 PST ---
std.c.stdlib now just contains a public import of core.stdc.stdlib, so I'm reassigning this report to druntime.  I've also fixed it in my druntime fork and sent a pull request:

https://github.com/D-Programming-Language/druntime/pull/2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5271


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

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


--- Comment #4 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2011-02-14 05:50:02 PST ---
https://github.com/D-Programming-Language/druntime/commit/1006fa114e48147a338f6cee3a0cadfe17e59218

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