[Issue 6646] [SafeD] array.reserve is not @safe/trusted
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 6 01:16:25 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=6646
--- Comment #9 from monarchdodra at 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: -------
More information about the Digitalmars-d-bugs
mailing list