[Issue 6923] New: Not restrictive initialization semantics
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 9 19:56:47 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6923
Summary: Not restrictive initialization semantics
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: minor
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-11-09 19:56:08 PST ---
This is not exactly a bug report, it's just an example of code that shows a
possible design/implementation problem.
Code by Timon Gehr:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=148455
A comment:
> I think the current initialization semantics are not restrictive enough.
-------------------------
immutable(int)* p;
void foo() { // checks if values pointed to by p are really immutable
static int[immutable(int)*] mem;
if (p !in mem)
mem[p] = *p;
else
assert(mem[p] == *p); // fail.
}
struct Foo {
immutable int x;
this(int y) {
p = &x;
foo();
x = 1;
foo();
}
}
void main() {
Foo(2);
}
--
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