digitalmars.D.bugs - [Issue 7419] New: [2.058/CTFE] Constructor of struct is overwritten inside a unittest with -inline
- d-bugmail puremagic.com (39/39) Feb 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (25/25) Feb 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (11/11) Feb 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (13/19) Feb 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (10/31) Feb 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (11/11) Feb 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
- d-bugmail puremagic.com (13/13) Feb 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7419
http://d.puremagic.com/issues/show_bug.cgi?id=7419 Summary: [2.058/CTFE] Constructor of struct is overwritten inside a unittest with -inline Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: CTFE Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: kennytm gmail.com --- Comment #0 from kennytm gmail.com 2012-02-01 11:48:03 PST --- Test case: ----------------- struct X7419 { double x; this(double x) { this.x = x; } } unittest { enum x = { auto p = X7419(3); return p.x; }(); static assert(x == 3); } ----------------- Compile with: dmd -unittest -inline -c test7419.d Gives the unexpected error: test7419.d(12): Error: static assert (nan == 3) is false The bug was introduced in commit 40160a53a0c72bfbad2e0ad36ec8f1ccbb76ce8d. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au AssignedTo|nobody puremagic.com |clugdbug yahoo.com.au --- Comment #1 from Don <clugdbug yahoo.com.au> 2012-02-01 13:29:03 PST --- It doesn't need unittest. The -inline seems to be necessary, I presume it's creating a ref variable. struct X7419 { double x; this(double x) { this.x = x; } } void bug7419() { enum x = { auto p = X7419(3); return p.x; }(); static assert(x == 3); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com --- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2012-02-01 21:24:53 PST --- Linky: https://github.com/D-Programming-Language/dmd/commit/40160a53a0c72bfbad2e0ad36ec8f1ccbb76ce8d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 --- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2012-02-01 22:00:23 PST --- Looking at that git commit, if I add back in the following code that was elided: 3450a3451,3459#if 1 if (op==TOKconstruct && this->e1->op==TOKvar && this->e2->op != TOKthis && this->e2->op != TOKcomma && ((VarExp*)this->e1)->var->storage_class & STCref) wantRef = true; #endifthen it works. Note that when -inline is used, the only function that gets inlined is the constructor call. Note the comment for the elision, saying it is to fix something with foreach, yet foreach is not in this example, I think the problem is in CTFE. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 --- Comment #4 from Don <clugdbug yahoo.com.au> 2012-02-02 01:12:07 PST --- (In reply to comment #3)Looking at that git commit, if I add back in the following code that was elided: 3450a3451,3459That code was introduced as a hack to get ref foreach to work in CTFE, but it isn't correct (the != TOKthis and != TOKcomma is a hack). Later, after fixing some other bugs, ref foreach works without it. I have made a proper fix, which I will post tonight. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------#if 1 if (op==TOKconstruct && this->e1->op==TOKvar && this->e2->op != TOKthis && this->e2->op != TOKcomma && ((VarExp*)this->e1)->var->storage_class & STCref) wantRef = true; #endifthen it works. Note that when -inline is used, the only function that gets inlined is the constructor call. Note the comment for the elision, saying it is to fix something with foreach, yet foreach is not in this example, I think the problem is in CTFE.
Feb 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 --- Comment #5 from github-bugzilla puremagic.com 2012-02-03 23:20:50 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/127d0110b839e5bdc2997ae0b586b1e93c7c8daa 7419 [2.058/CTFE] Constructor of struct is overwritten with -inline The logic for ref variables was incorrect. Stripping out _all_ of the funky foreach code fixes it. Fixes bug 7419. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7419 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2012-02-04 00:59:51 PST --- Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/467cf6687f60dbb4180df036bd0508b9ce408d19 fix issue 6504, fix issue 7419 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 04 2012