www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12885] New: const union wrongly converts implicitly to mutable

https://issues.dlang.org/show_bug.cgi?id=12885

          Issue ID: 12885
           Summary: const union wrongly converts implicitly to mutable
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: ASSIGNED
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nilsbossung googlemail.com
          Reporter: nilsbossung googlemail.com
        Depends on: 12883

---
union U
{
    int i;
    int* p;
}
void main()
{
    const U c;
    U m = c;
}
---

This has been enabled by the fix to issue 11257. I think this behaviour is not
acceptable. The change has been made to "allow const(Rebindable) to Rebindable
conversion". I think this should be implemented in Rebindable itself, as that's
the place where we can give the guarantee not to alter the wrapped
const/immutable data. alias this can be used for this once issue 12883 is
fixed.

--
Jun 09 2014