Bug 7920 – Possible to return const object through mutable Object

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-15T23:20:00Z
Last change time
2012-04-16T05:30:03Z
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2012-04-15T23:20:04Z
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.
Comment #1 by schveiguy — 2012-04-16T05:30:03Z
*** This issue has been marked as a duplicate of issue 3731 ***