[Issue 7920] New: Possible to return const object through mutable Object

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 15 23:19:16 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7920

           Summary: Possible to return const object through mutable Object
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: doob at me.com


--- Comment #0 from Jacob Carlborg <doob at me.com> 2012-04-15 23:20:04 PDT ---
class Foo
{
    Foo f;

    Foo bar () const
    {
        return f;
    }
}

The above code results in the compile error:

Error: cannot implicitly convert expression (this.f) of type const(Foo) to
test.Foo

This is just as expected, but if I change "bar" to:

Object bar () const
{
    return f;
}

I don't get any errors.

-- 
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