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

[wasm2c] Strange issue with double parsing in msvc #2422

Closed
sbc100 opened this issue May 14, 2024 · 5 comments
Closed

[wasm2c] Strange issue with double parsing in msvc #2422

sbc100 opened this issue May 14, 2024 · 5 comments

Comments

@sbc100
Copy link
Member

sbc100 commented May 14, 2024

For some reason INT_MIN is not parsing correctly under MSVC..

#include <stdio.h>

int main() {
  double x = -2147483648;
  double y = -2147483648L;
  double z = -2147483648.0;
  printf("%f\n", x);
  printf("%f\n", y);
  printf("%f\n", z);
}

Under MSVC this produces:

2147483648.000000
2147483648.000000
-2147483648.000000

i.e. only adding .0 at the end causes the sign bit to be preserved.

Gcc and clang both (correctly I believe) produce:

-2147483648.000000
-2147483648.000000
-2147483648.000000
@SoniEx2
Copy link
Contributor

SoniEx2 commented May 14, 2024

isn't this #2389 ?

@SoniEx2
Copy link
Contributor

SoniEx2 commented May 14, 2024

INT_MIN/etc are notorious for being a pain as a numeric constant, the usual workaround is to write it as an expression (-2147483647 - 1).

(something about it being technically UB?)

@sbc100
Copy link
Member Author

sbc100 commented May 14, 2024

Ah yes, I think #2389 will fix this. My fix was to append .0 which also seems to work.

@sbc100
Copy link
Member Author

sbc100 commented May 14, 2024

-fsanitize=undefined doesn't warn here..

@sbc100
Copy link
Member Author

sbc100 commented May 14, 2024

Closing as duplicate of #2388

@sbc100 sbc100 closed this as completed May 14, 2024
sbc100 added a commit that referenced this issue May 14, 2024
sbc100 added a commit that referenced this issue May 15, 2024
sbc100 added a commit that referenced this issue May 15, 2024
sbc100 added a commit that referenced this issue May 15, 2024
sbc100 added a commit that referenced this issue May 15, 2024
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

2 participants