-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue 21424 - Variable is incremented twice #11997
Conversation
|
Thanks for your pull request and interest in making D better, @BorisCarvajal! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#11997" |
ae89906 to
5e7ba79
Compare
be32787 to
97ce08d
Compare
src/dmd/backend/cgelem.d
Outdated
| elem *econv = e.EV.E1; | ||
| while (OTconv(econv.Eoper)) | ||
| { | ||
| if (econv.EV.E1.Eoper == OPcomma) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (econv.EV.E1.Eoper != OPcomma)
{
econv = econv.EV.E1;
continue;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good
97ce08d to
7b7cd2f
Compare
Test case:
Here DMD internally generates something like:
cast(ulong)cast(int) (tmp = pos++ + &buf, *tmp) += numThat expression had to be converted to:
(tmp = pos++ + &buf, cast(ulong)cast(int) *tmp) += numbut the implementation worked only for one cast (fixed now). And because of that the compiler ended up creating an assign operation duplicating the comma exp in both sides:
(tmp = pos++ + &buf, *tmp) = cast(...)(tmp = pos++ + &buf, *tmp) + num