[Issue 6753] New: "Reinterpret" cast of array to a tail const one doesn't work inside @trusted
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 1 14:10:14 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6753
Summary: "Reinterpret" cast of array to a tail const one
doesn't work inside @trusted
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2011-10-01 14:09:34 PDT ---
This used to work on 2.055:
struct Interval{ int a,b; }
@safe struct S
{
int[] arr;
@trusted @property auto byInterval() const
{
return cast(const(Interval)[])arr;
}
}
Now on 2.056head (on commit fac2d5107a003320ce5389de04fcb6705e3795c9)
it's rejected with:
Error: cast from const(int[]) to const(Interval)[] not allowed in safe code
Maybe byInterval somehow doesn't override it's safety level to "trusted".
The following workaround works which makes me think it's a bug in upcoming
2.056.
@safe struct S
{
int[] arr;
@trusted @property auto byInterval() const
{
const(int)[] tmp = arr;
return cast(const(Interval)[])tmp;
}
}
--
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