https://issues.dlang.org/show_bug.cgi?id=19961
Issue ID: 19961
Summary: context pointer does not apply qualifiers properly
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
void main()
{
int i = 42;
// const should not be able to access mutable.
int* p = &i;
auto dg2 = delegate int() const { return *p; };
assert(dg2() == i);
}
fails to error.
Also
void main()
{
int i = 42;
// shared cannot access mutable
int* p = &i;
auto dg2 = delegate int() shared { return *p; };
assert(dg2() == i);
}
errors, the context should be captured as shared so that should be allowed.
Issue 15306 declared this accepts invalid as shared aliasing but I believe that
is incorrect. Shared doesn't offer any useful guaruntees on that front anyway.
--