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

cast to void produces wrong code #13

Closed
TotallyGamerJet opened this issue Jul 13, 2021 · 1 comment · Fixed by #29
Closed

cast to void produces wrong code #13

TotallyGamerJet opened this issue Jul 13, 2021 · 1 comment · Fixed by #29
Labels
bug Something isn't working

Comments

@TotallyGamerJet
Copy link
Contributor

the following c code:

int a = 0;
(void)a;

should produce:

var a int = 0
_ = a

instead, it produces:

var a int = 0
a 

which doesn't compile in go because the variable is evaluated but not used

@dennwc
Copy link
Contributor

dennwc commented Jul 13, 2021

There's a test case, but I don't remember why I decided to force the compilation error. I use cxgo for a pretty specific codebase, so I might have done it due to some issue there.

In any case, I agree that it should produce _ = a by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants