[Issue 2728] New: Bogus Error message on const ref return
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 11 09:43:56 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2728
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 at digitalmars.com
ReportedBy: dsimcha at 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
correctness.
--
More information about the Digitalmars-d-bugs
mailing list