Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
June 03, 2012 [Issue 8192] New: inconsistent behavior of initialized immutable instance fields | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8192 Summary: inconsistent behavior of initialized immutable instance fields Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: timon.gehr@gmx.ch --- Comment #0 from timon.gehr@gmx.ch 2012-06-03 10:19:14 PDT --- DMD 2.059: struct S{ immutable y = 1; } void main(){ writeln(S.y); // ok writeln(&S.y); // error with(S){ writeln(&y); // ok assert(*&y==y); // fail } } Either the code should run through or all the commented lines should fail to compile. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 03, 2012 [Issue 8192] inconsistent behavior of initialized immutable instance fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8192 --- Comment #1 from timon.gehr@gmx.ch 2012-06-03 10:23:29 PDT --- Better test case: struct S{ immutable y = 1; } void main(){ assert(S.y==1); // ok assert(&S.y!is null); // compile error with(S){ assert(&y!is null); // ok assert(*&y==y); // fail } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 03, 2012 [Issue 8192] inconsistent behavior of initialized immutable instance fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8192 art.08.09@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |art.08.09@gmail.com --- Comment #2 from art.08.09@gmail.com 2012-06-03 12:09:51 PDT --- Worse, the struct layout changes when an immutable field has an initializer. struct S { immutable int x = 1; int y; } struct S2 { int x; int y; } void main(){ S s; S2 s2; static assert(s.y.offsetof==s2.y.offsetof); // fails } Trying to take the address of s.x fails with 'not an lvalue', etc. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 03, 2012 [Issue 8192] inconsistent behavior of initialized immutable instance fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8192 --- Comment #3 from art.08.09@gmail.com 2012-06-03 12:25:49 PDT --- A better example: struct S { immutable int x = 1; int y; } struct S2 { immutable int x; int y; } void main(){ S s; S2 s2; static assert(s.y.offsetof==s2.y.offsetof); // fails } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 27, 2012 [Issue 8192] inconsistent behavior of initialized immutable instance fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8192 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |DUPLICATE --- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-26 16:03:42 PST --- Another case of Issue 3449 methinks. *** This issue has been marked as a duplicate of issue 3449 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation