Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 02, 2011 [Issue 6759] New: missing initialization in foreach with alias this | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6759 Summary: missing initialization in foreach with alias this Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dawg@dawgfoto.de --- Comment #0 from dawg@dawgfoto.de 2011-10-02 05:03:02 PDT --- struct Range { size_t front() { return 0; } void popFront() { empty = true; } bool empty; } struct ARange { Range range; alias range this; } void main() { ARange arange; assert(arange.front == 0); foreach(e; arange) {} } --- Foreach creates a reference to arange. The expression that initializes the reference is dropped for alias this aggregates. This is a regression introduced by https://github.com/D-Programming-Language/dmd/commit/6a2aefdb468d20aa8d498c8930c2613d78a91238 as a fix to #2781. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 02, 2011 [Issue 6759] missing initialization in foreach with alias this | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6759 --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-02 12:37:22 PDT --- Your patch was already merged (commit: f53ff46), and it looks correct to me the fixing lack of merging prelude before semantic. But, your sample code works before merging (commit: 07f719e), so that code is not test case of this issue. Do you have right test case? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 02, 2011 [Issue 6759] missing initialization in foreach with alias this | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6759 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-10-02 12:54:32 PDT --- https://github.com/D-Programming-Language/dmd/commit/fed2faabc3ca9f67a429293eee82ae597061fea8 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 05, 2011 [Issue 6759] missing initialization in foreach with alias this | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6759 --- Comment #3 from dawg@dawgfoto.de 2011-10-05 12:04:09 PDT --- (In reply to comment #1) > Your patch was already merged (commit: f53ff46), and it looks correct to me the fixing lack of merging prelude before semantic. > > But, your sample code works before merging (commit: 07f719e), so that code is not test case of this issue. > > Do you have right test case? This is probably due to constant folding or optimization. The merged version has 'assert(e == 0);' in the loop body. -- 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