digitalmars.D.bugs - [Issue 1312] New: invariant storage class within a struct/class
- d-bugmail puremagic.com (38/38) Jul 03 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1312
- d-bugmail puremagic.com (12/12) Sep 10 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1312
http://d.puremagic.com/issues/show_bug.cgi?id=1312 Summary: invariant storage class within a struct/class Product: D Version: 2.002 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: Daniel919 web.de There is an unwanted behaviour when using an invariant storage class within a struct/class. ------------------------------------------------------------------------ import std.stdio; struct MyStruct { int x = 1; invariant int y = 2; //void resety() { y = 3; }; //error: constant y is not an lvalue - as expected /* alternatives, that work as expected: const int y = 2; static invariant int y = 2; final int y = 2; //but this takes up storage for each instance */ } void main() { MyStruct mystruct; mystruct.x = 1; //ok //mystruct.y == 1, expected: 2 //mystruct.y = 2; //no error, but mystruct.x also becomes 2 writefln("mystruct.sizeof: %s mystruct.x: %s mystruct.y: %s", mystruct.sizeof, mystruct.x, mystruct.y); } --
Jul 03 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1312 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |FIXED --- Comment #1 from Don <clugdbug yahoo.com.au> 2009-09-10 14:16:16 PDT --- This was fixed in DMD2.022 or earlier. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 10 2009