www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6333] New: The 'capacity' function is not pure/nothrow/ safe.

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 16 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6333


Steven Schveighoffer <schveiguy yahoo.com> changed:

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



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: -------
Jul 18 2011
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 16 2012