Thread overview
[Issue 6333] New: The 'capacity' function is not pure/nothrow/@safe.
Jul 16, 2011
kennytm@gmail.com
Feb 16, 2012
Rob Jacques
July 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6333

           Summary: The 'capacity' function is not pure/nothrow/@safe.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-07-16 01:59:47 PDT ---
As titled. Probably it is expected, or not.

Test case:
----------------------------------------
pure @safe nothrow int f6333() {
    auto x = [1,3];
    return x.capacity;
}
----------------------------------------
x.d(3): Error: pure function 'f6333' cannot call impure function 'capacity'
x.d(3): Error: safe function 'f6333' cannot call system function 'capacity'
x.d(3): Error: capacity is not nothrow
x.d(1): Error: function x.f6333 'f6333' is nothrow yet may throw
----------------------------------------

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


Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com


--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-07-18 07:34:13 PDT ---
I don't know if capacity can be pure.  I haven't thought about the implications of making it pure, maybe there is a way.  It seems like a reasonable property.

However, it could technically be nothrow.  However, it's technically an alias for arr.reserve(0), and reserve could definitely throw.

I'm unsure how to deal with that.  Maybe I need to separate the runtime function into two, one that's pure nothrow, the other which might allocate memory.

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


Rob Jacques <sandford@jhu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |sandford@jhu.edu


--- Comment #2 from Rob Jacques <sandford@jhu.edu> 2012-02-16 14:28:32 PST ---
I wrote a patch which address this for capacity and reserve. Here's pull request:

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

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