[Issue 4068] New: Returning references to const members yield error message

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 5 05:57:31 PDT 2010


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

           Summary: Returning references to const members yield error
                    message
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: simen.kjaras at gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras at gmail.com> 2010-04-05 05:57:30 PDT ---
The following should IMO compile:

struct S {
  const int n;
  const ref int bar( ) {
    return n;
  }
}

It fails on the line 'return n;', with the message 'Error: can only initialize
const member n inside constructor'

The same behavior exists with immutable members and references.

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