www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7691] New: A pure std.math.floor

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

           Summary: A pure std.math.floor
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



import std.math: floor;
pure void main() {
    enum double x = floor(2.3);
}


DMD 2.059head gives:

test.d(3): Error: pure function 'main' cannot call impure function 'floor'
...\dmd2\src\phobos\std\math.d(1917): Error: floorl cannot be interpreted at
compile time, because it has no available source code
test.d(3):        called from here: floor(2.3L)


So there are two problems here, floor is not pure and it can't run at
compile-time.

std.math.fmod() too isn't pure.

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


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



Most std.math functions need use asm; we need to write ctfe versions for them.

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





 Most std.math functions need use asm; we need to write ctfe versions for them.
But note that I'd like to use it mostly in run-time code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 28 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7691




Does dmd even support pureness checking for asm blocks? If not, I'm not sure
when we will be able to mark asm functions as pure.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 Does dmd even support pureness checking for asm blocks? If not, I'm not sure
 when we will be able to mark asm functions as pure.
asm blocks are ignored for pureness checking. And I think it has to be that way. In the asm for BigInt, at one point I write to a static variable. That variable is never read from, EVER. It's a trick to force Intel processors to stay in sync every pass through the loop. It would be impossible to enforce, anyway. BTW: floor() isn't pure, because floorl() isn't pure, because floorl(), being a C function, may set the matherr variable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 28 2012