Thread overview
[Issue 11257] New: Allow whole implicit conversion if one or more overlapped field could.
Oct 14, 2013
Kenji Hara
Oct 14, 2013
Kenji Hara
Oct 15, 2013
Walter Bright
October 14, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11257

           Summary: Allow whole implicit conversion if one or more
                    overlapped field could.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-14 04:00:35 PDT ---
Compiler rejects this code so the implicit conversion from const(R) to R breaks mutable field 'stripped' const-correctness.

struct R
{
    union
    {
        const(Object) original;
        Object stripped;
    }
}
void main()
{
    const R cr;
    R mr = cr;  // Error: cannot implicitly convert expression
                // (cr) of type const(R) to R
}

However, I think this is a little restricted behavior. Because qualified and overlapped field is D-specific feature. It's mostly used for bypassing the restriction of const qualifier. Therefore, in many case it would be protected by private access specifier.

The feature is necessary in order to allow const(Rebindable) to Rebindable
conversion.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-14 05:57:34 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2665

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



--- Comment #2 from github-bugzilla@puremagic.com 2013-10-14 20:51:11 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0f00e6b6f29707f7a18b6e559aecf6bca50fca90
fix Issue 11257 - Allow whole implicit conversion if one or more overlapped
field could.

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


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