[Issue 9149] New: 'const' is broken
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 13 04:43:48 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9149
Summary: 'const' is broken
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 2012-12-13 04:43:47 PST ---
Delegates cannot implicitly convert to const without breaking const guarantees.
Reading a mutable delegate out of a const reference therefore must be a compile
error. (for the same reason a mutable member function cannot be called on a
const receiver.)
import std.stdio;
class T{
int x;
int delegate()pure b;
this(){ b = ()pure=>x++; }
}
void main(){
auto s=new T();
const c = s.b; // ok, should fail
const t=s;
writeln(c(), c(), c(), c());
writeln(t.b(), t.b(), t.b(), t.b()); // ok, should fail
}
--
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