Thread overview
[Issue 6753] New: "Reinterpret" cast of array to a tail const one doesn't work inside @trusted
Oct 01, 2011
Dmitry Olshansky
[Issue 6753] Regression(2.055beta) "Reinterpret" cast of array to a tail const one doesn't work inside @trusted
Oct 22, 2011
Don
Oct 23, 2011
Kenji Hara
Oct 23, 2011
Walter Bright
October 01, 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@puremagic.com
        ReportedBy: dmitry.olsh@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh@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: -------
October 22, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6753


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|"Reinterpret" cast of array |Regression(2.055beta)
                   |to a tail const one doesn't |"Reinterpret" cast of array
                   |work inside @trusted        |to a tail const one doesn't
                   |                            |work inside @trusted


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-10-22 13:14:29 PDT ---
Regression was introduced by this commit:

https://github.com/D-Programming-Language/dmd/commit/a1566e372bf48c2b414ead04104569562202be1a

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6753


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
           Platform|Other                       |All


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-23 02:40:53 PDT ---
https://github.com/D-Programming-Language/dmd/pull/470

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6753


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-10-23 11:26:58 PDT ---
https://github.com/D-Programming-Language/dmd/commit/4f06a053521991d8009d16f213f35de5ccc2db8f

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------