[Issue 19961] New: context pointer does not apply qualifiers properly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 14 08:05:25 UTC 2019
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: nobody at puremagic.com
Reporter: iamthewilsonator at hotmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list