[Issue 11257] New: Allow whole implicit conversion if one or more overlapped field could.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 14 04:00:36 PDT 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 at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at 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: -------


More information about the Digitalmars-d-bugs mailing list