[Issue 10368] New: `immutable pure` constructors must not be allowed for mutable construction
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 15 13:54:05 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10368
Summary: `immutable pure` constructors must not be allowed for
mutable construction
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid, spec
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-06-16 00:54:04 MSD ---
As `pure` functions can access `immutable` static data `immutable pure`
constructors must not be allowed for mutable construction.
So this code must be rejected:
---
immutable int i;
class C
{
int* p;
this() immutable pure
{ p = &i; }
}
void main()
{
++*new C().p; // changes `i`
}
---
Current behaviour is already documented (dlang.org pull #317) so specs have to
be changed too.
--
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