August 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6646



--- Comment #9 from monarchdodra@gmail.com 2013-08-06 01:16:23 PDT ---
(In reply to comment #8)
> (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?

I was able to make it work simply by calling a dummy postblit:

reserve(T)(T[] t)
{
    if (is(typeof({T t2 = t;})))
        if (0)
            T t2 = t;

    //Call C-reserve function here.
}

The forced postblit call makes sure the inference is ocrrectly computed.
Unfortunately:
1) The C function is still marked nothrow, so all hell probably breaks loose
*should* an exception be thrown
2) Hackish as hell. Might be worth it to find a better workaround.

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


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

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


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


monarchdodra@gmail.com changed:

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


--- Comment #10 from monarchdodra@gmail.com 2013-09-09 11:47:53 PDT ---
It's not fixed, because reserve is not @safe 100% of the time either.

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

The problem is that everything is run in druntime, as an non-template extern(C) call to a function that takes a TypeInfo. So no inference here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »