[Issue 13506] @safe cartesianProduct.array

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 20 21:00:44 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13506

hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh at quickfur.ath.cx

--- Comment #1 from hsteoh at quickfur.ath.cx ---
This bug appears unrelated to cartesianProduct; it's ultimately caused by a
particular overload of Phobos internal function std.conv.emplaceImpl. It just
so happens that other similar range-based calls to std.array.array end up in
other, @safe instantiation paths, so the problem isn't (yet) exposed elsewhere
(though you can probably find the same problem showing up elsewhere if you knew
where to look).

The following Phobos patch fixes this problem, but I'm not ready to submit that
as a PR yet because I'm not 100% confident that it's the correct fix (sticking
@trusted on that call may be a bit too blunt of an instrument; probably some
other static checks should be added to make sure that it is in fact
@trust-worthy).

------snip------
diff --git a/std/array.d b/std/array.d
index b9012e4..8ad8cc3 100644
--- a/std/array.d
+++ b/std/array.d
@@ -2567,7 +2567,9 @@ if (isDynamicArray!A)
             else
                 auto ref uitem() @trusted nothrow @property { return
cast(Unqual!T)item; }

-            emplaceRef!(Unqual!T)(bigData[len], uitem);
+            () @trusted {
+                emplaceRef!(Unqual!T)(bigData[len], uitem);
+            }();

             //We do this at the end, in case of exceptions
             _data.arr = bigData;

------snip------

--


More information about the Digitalmars-d-bugs mailing list