Program exit code has incorrect modulo
Bug #552413 reported by
Matt Giuca
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Fix Released
|
Low
|
Matt Giuca |
Bug Description
The current algorithm for setting the return value of the program is to take the result of main (a bignum) and convert it into a machine-size int (the OS typically mods it into a byte):
r := r % MAX_INT
This is incorrect as MAX_INT maps to 0, -1 maps to 0, and MAX_INT+1 maps to 1.
MAX_INT and -1 should map to MAX_INT; MAX_INT+1 should map to 0.
Thus the formula should be:
r := r % (MAX_INT+1)
Related branches
Changed in mars: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Fixed in trunk r991.