www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6753] New: "Reinterpret" cast of array to a tail const one doesn't work inside trusted

reply d-bugmail puremagic.com writes:
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



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: -------
Oct 01 2011
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 22 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 23 2011
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 23 2011