Jump to page: 1 2
Thread overview
[Issue 6646] New: [SafeD] array.reserve is not @safe/trusted
Sep 11, 2011
Dmitry Olshansky
Aug 05, 2013
Dmitry Olshansky
Sep 09, 2013
Dmitry Olshansky
September 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6646

           Summary: [SafeD] array.reserve is not @safe/trusted
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: dmitry.olsh@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2011-09-11 10:13:37 PDT ---
I'm not sure if it's druntime or DMD problem.

Testcase:

@safe void bug()
{
    int[] a;
    a.reserve(10);
}

Fails to compile with:
Error: safe function 'bug' cannot call system function 'reserve'

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



--- Comment #1 from hsteoh@quickfur.ath.cx 2013-07-01 12:01:16 PDT ---
IMO, reserve() should be at least @trusted. What's the use of safeD if even language constructs like array.reserve can't be used?

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


Steven Schveighoffer <schveiguy@yahoo.com> changed:

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


--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2013-07-01 13:27:43 PDT ---
It should be @trusted.

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



--- Comment #3 from hsteoh@quickfur.ath.cx 2013-07-02 09:25:32 PDT ---
https://github.com/D-Programming-Language/druntime/pull/536

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



--- Comment #4 from github-bugzilla@puremagic.com 2013-07-02 12:28:37 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/032bac64ef3e354da65da38314c51af09eebcf05 Fix issue 6646: array.reserve should be callable from SafeD.

https://github.com/D-Programming-Language/druntime/commit/fa85c1b413cbe81416f02995cfefe6107a4cbb4e Merge pull request #536 from quickfur/issue6646

Fix issue 6646: array.reserve should be callable from SafeD.

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


Alex Rønne Petersen <alex@lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex@lycus.org
         Resolution|                            |FIXED


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


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |monarchdodra@gmail.com
         Resolution|FIXED                       |


--- Comment #5 from monarchdodra@gmail.com 2013-07-29 04:17:04 PDT ---
I think this change is wrong. reserve can call postblit, wich may end up being
unsafe (or throwing).

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



--- Comment #6 from hsteoh@quickfur.ath.cx 2013-07-29 09:12:32 PDT ---
Hmph. I wish there was a consistent way of propagating attributes, or saying "function X's purity depends on argument Y" or something along those lines.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6646



--- Comment #7 from Steven Schveighoffer <schveiguy@yahoo.com> 2013-08-05 13:38:51 PDT ---
This can be fixed, since reserve is a template and not a compiler-builtin.

Unfortunately, we need to manually propagate the @safe/@nothrow to the high level reserve call. something like:

@safe @nothrow reserve(T)(T[] t) if(isPostblitSafe!T && isPostblitNothrow!T)

etc.

Ugly...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6646



--- Comment #8 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2013-08-05 14:13:05 PDT ---
(In reply to comment #7)
> This can be fixed, since reserve is a template and not a compiler-builtin.
> 
> Unfortunately, we need to manually propagate the @safe/@nothrow to the high level reserve call. something like:
> 
> @safe @nothrow reserve(T)(T[] t) if(isPostblitSafe!T && isPostblitNothrow!T)
> 
> etc.
> 
> Ugly...

Shouldn't auto-inference help + local @trusted/nothrow lambdas to encapsulate dangerous code?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2