Repository navigation
Fix Numbers.Int_base.compare - #13606
Conversation
There was a problem hiding this comment.
This is fine.
Note: unless I am missing something, the trunk code should be correct also with negative integers, as long as there is no overflow during the computation. So the problem should be with really large inputs (in absolute value), for example if one of the values is min_int.
I believe the point is rather that the code is correct if both inputs are nonnegative so you need at least one negative value (which does not need to be of high magnitude, if the nonnegative input is itself large) to trigger a bug. For context the issue originally occurred when using (large and potentially negative) hashes as keys. |
The
comparefunction used for integers in (parts of) the compiler is wrong (i.e. not suitable for use as argument ofMap.Make). This eventually caused bugs in the flambda-backend compiler, which was building maps with potentially negative numbers as keys (see oxcaml/oxcaml#3268 for the same fix there).