[Issue 15660] break "immutable" with pure function and mutable reference params
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Aug 25 18:22:19 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15660
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #6 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to Steven Schveighoffer from comment #4)
> (In reply to Iakh from comment #3)
> > (In reply to Steven Schveighoffer from comment #2)
> > Even this works:
> > import std.stdio;
> >
> > int[] f(void[] a) @safe pure
> > {
> > return cast(int[])a;
> > }
>
> In this case, you are using a cast. The compiler pretty much gives up trying
> to ensure anything when you cast, so I think it's OK to allow that.
>
> Although, I thought such a cast wouldn't work in @safe code.
And indeed, it no longer is compilable:
test.d(3): Error: cast from void[] to int[] not allowed in safe code
--
More information about the Digitalmars-d-bugs
mailing list