-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Dart2js miscompiles -1>>1 #21626
Comments
This comment was originally written by [email protected] In the non-compile time constant case I get the following in out.js: _shrOtherPositive$1: function(receiver, other) { The problem seems to be that this functions uses >>>. I have no idea why it's written that way. In fact I'm mystified that dart2js wants to insert such a wrapper function anyway. Why not compile ">>" straight to Javascript's ">>". After all you do not support >32bit integers with shifts in dart2js and silently produce incorrect results in that case. |
This comment was originally written by [email protected] Here is a little program that shows the shrOtherPositive case where the expression is miscomputed at runtime. Attachment: |
This comment was originally written by [email protected] I don't think issue #21626 should be merged into issue #1533. Fixing issue #1533 requires a complex solution, such as big integers, new types,... Issue #21626 is a straight-forward bug where dart2js could easily produce correct code by simply compiling Dart's >> into JavaScript's >>. There is absolutely no reason not to fix issue #21626 with the next Dart update, whereas issue #1533 will probably remain unfixed for a long time. |
The use of >>> is deliberate. The bit level operators |, &, ^ , << and >> only work in JavaScript for a limited range of numbers, basically 32-bit numbers. We studied a number of programs to see which should be supported. All the bit-level operations in dart2js have the following property: I hope this explanation de-mystifies the behaviour. |
This issue was originally filed by [email protected]
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Expected output: -1
Actual printout: 4294967295
What version of the product are you using?
Dart-to-JavaScript compiler (dart2js) version: 1.7.2
On what operating system?
Ubuntu 12.04
Please provide any additional information below.
dart2js computes -1>>1 at compile and puts the string 4294967295 directly into out.js but the problem is not limited to this case. The same bug happens when the computation is actual performed at runtime.
The text was updated successfully, but these errors were encountered: