www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2728] New: Bogus Error message on const ref return

reply d-bugmail puremagic.com writes:

           Summary: Bogus Error message on const ref return
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com

Version 2.026, not sure why that's not an option yet in the version list.

struct Const {
    uint[2] num;

    ref uint opIndex(uint index) const {
        return num[index];

Error message by compiler:
Error: cast(uint)(this.num[index]) is not an lvalue

This may be technically correct if the compiler is trying to cast away const to
return the reference, but the error message should really be related to the
fact that you can't return a non-const reference here without violating const

Mar 11 2009
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #1 from bugzilla digitalmars.com  2009-04-01 13:55 -------
Fixed DMD 2.027

Apr 01 2009