digitalmars.D.bugs - [Issue 7334] New: autogenerated CTOR don't check invariant
- d-bugmail puremagic.com (78/78) Jan 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7334
- d-bugmail puremagic.com (12/12) Jan 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7334
http://d.puremagic.com/issues/show_bug.cgi?id=7334 Summary: autogenerated CTOR don't check invariant Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: devbai mnet-mail.de --- Comment #0 from Devbai <devbai mnet-mail.de> 2012-01-21 09:07:46 PST --- Hello I miss the invariant-check during the execution of the auto-generated ctor. Following programm .... ************** import std.stdio; class ClassA { private int mValue; // with the following default-CTOR would be the invariants be checked: // this() // {} property { public int value() const { return mValue; } public void value(int newValue) { mValue = newValue; } } invariant() { writeln("checking INVARIANT ClassA (mValue: ", mValue, ")"); assert ( mValue>0, "NOT mValue>0"); } } public static void main () { writeln("creating ClassA"); ClassA aObject = new ClassA(); // may not pass; // because ClassA has no good CTOR writeln("reading value:"); writeln(aObject.value); } ************** compiled with "DMD64 D Compiler v2.057" and run will shown this output: ************** core.exception.AssertError src/bug/bugNoInvariantCheckWithAutoCTOR/TestAppBugNoInvariantCheckWithAutoCTOR.d(24): NOT mValue>0 ---------------- (_d_assert_msg+0x1f) [0x448323] ./(void TestAppBugNoInvariantCheckWithAutoCTOR.ClassA.__invariant()+0x5e) [0x443f46] ./(void invariant._d_invariant(Object)+0x20) [0x4489d0] ./(const( property int function()) TestAppBugNoInvariantCheckWithAutoCTOR.ClassA.value+0x11) [0x443ea9] ./(_Dmain+0x50) [0x443f98] ./(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x44892f] ./(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x4484d6] ./(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x42) [0x448982] ./(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x4484d6] ./(main+0xd3) [0x448467] /lib/libc.so.6(__libc_start_main+0xfe) [0x7ffe8348ed8e] ---------------- creating ClassA reading value: checking INVARIANT ClassA (mValue: 0) ************** I would expect that the assert should throw an Error during the ctor. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 21 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7334 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |DUPLICATE --- Comment #1 from yebblies <yebblies gmail.com> 2012-01-22 12:21:31 EST --- *** This issue has been marked as a duplicate of issue 519 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 21 2012