The following code can be compiled in dmd v2.067-devel-590d4a9 but it should not.
------
import std.variant;
void main() @safe {
auto foo() @system { return 3; }
auto v = Variant(&foo);
v(); // foo is called in safe code!?
}
------
Currently whole part of std.variant is marked as trusted but it should not because the safety of the functions or methods in this module
depends on the components which are stored in VariantN, Algebraic etc.
Comment #1 by hsteoh — 2014-09-26T19:31:12Z
Yeah, only those parts of Variant that deal with casting between types should be considered as @trusted; it's a very bad idea to make a whole big block of code @trusted when its actual semantics depends on arbitrary template parameters.
Comment #2 by hsteoh — 2014-09-26T19:36:32Z
Probably the most straightforward way to fix this bug is to remove @trusted: from the top of the module, and then incrementally add @trusted around the smallest possible code units until the Phobos test suite passes.