Skip to content
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

Increment/dereference/assign combination returns a wrong value #744

Closed
kamphaus opened this issue Jun 12, 2018 · 0 comments
Closed

Increment/dereference/assign combination returns a wrong value #744

kamphaus opened this issue Jun 12, 2018 · 0 comments

Comments

@kamphaus
Copy link
Contributor

The following C code

char str[] = "abcdef";
char *p = str;
int pp = *p++ = 'z';
is_eq(pp, 'z');

works, but when transpiled pp will be equal to 'b' (it should be 'z').

kamphaus pushed a commit to kamphaus/c2go that referenced this issue Jun 12, 2018
kamphaus pushed a commit to kamphaus/c2go that referenced this issue Jun 12, 2018
elliotchance pushed a commit that referenced this issue Jun 17, 2018
A possible optimization is to only use a tempVar if the type of the left hand side is a pointer and the result is not.
The previous code (without tempVar) should work fine for if the LHS is not a pointer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant