-
Notifications
You must be signed in to change notification settings - Fork 684
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] MSVC miscompiles for certain fp constants #2388
Comments
Thanks for reporting this! Can you please test #2389 and see if it fixes the issue for you? There should probably be a test for this situation, ideally eventually upstream in the spec tests. I'm also nervous about MSVC's handling of wasm2c output for conversion instructions given https://github.com/WebAssembly/wabt/blob/main/src/c-writer.cc#L4851 and https://github.com/WebAssembly/wabt/blob/main/src/config.cc#L76 -- we should make sure this is also tested. |
@keithw, PTAL at this spec PR. |
#2389 looks good, no unexpected overhead either
|
it works fine on both endian |
Thanks, good idea. Done in #2389. |
Given WASM
and wasm2c conversion output
there is slight discrepancy in output of different compilers.
![image](https://private-user-images.githubusercontent.com/21180354/303864093-55ec26ae-6519-4608-8411-dd69933d7501.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU2NjE4NjIsIm5iZiI6MTcyNTY2MTU2MiwicGF0aCI6Ii8yMTE4MDM1NC8zMDM4NjQwOTMtNTVlYzI2YWUtNjUxOS00NjA4LTg0MTEtZGQ2OTkzM2Q3NTAxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA2VDIyMjYwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJiMWM1NzI4Yjg3NTY2M2JiZTM0ZGQ4Mjc4NzE1ZDQxOGVlZTczYWFjZGU1Y2Q0Yjc1NWVlNWZjYjM3NjE5ZWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.dPk2jSEDADScOk_ho1EfimcS9Ecjaryizh7vz4fw5UQ)
Clang & GCC correctly output
-2147483648.000000
MSVC throws warning (error with /sdl) and outputs
2147483648.000000
(notice absence of negative mark)https://godbolt.org/z/MrjMzdeKE
While the conversion output is likely correct according to C spec (at least Clang and GCC are not screaming with -Wall), it's very inconvenient for Windows users to do these fixups manually.
Proposal is to use alternative notation
which makes all tested compilers happy and correct.
![image](https://private-user-images.githubusercontent.com/21180354/303864381-ff7fcc00-c397-4d57-9694-daf822682fe7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU2NjE4NjIsIm5iZiI6MTcyNTY2MTU2MiwicGF0aCI6Ii8yMTE4MDM1NC8zMDM4NjQzODEtZmY3ZmNjMDAtYzM5Ny00ZDU3LTk2OTQtZGFmODIyNjgyZmU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA2VDIyMjYwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThjMGVkYmFhMmY5ZGZjNGQzYWMzZjMxYTI4MGM1NTQzMDg0MzczOTk4ZDk1ZTNiY2ZlMzI1MzMwY2M1N2JjMDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RxC4FXdXCKPNY4fN2iOa02ZCCqc8S1lHzZU0uOldakI)
https://godbolt.org/z/5sE4adbYd
The text was updated successfully, but these errors were encountered: