Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001052Core InformListspublic2012-12-04 05:252014-05-07 07:34
ReporterNRTurner 
Assigned Tograham 
PrioritynormalSeverityseriousReproducibilityalways
StatusclosedResolutionfixed 
Platformx86OSMac OS XOS Version10.6
Product Version6G60 
Target VersionFixed in Version6L02 
Summary0001052: List (of numbers) sorting produces incorrect result (Z-code)
DescriptionA list of numbers is not sorted in the expected order. Settings: Z8

>version
Release 1 / Serial number 121204 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD
Identification number: //667FA13F-8372-4312-B614-149CA0916DB1//
Standard interpreter 1.1 (3Z) / Library serial number 080126
Standard Rules version 2/090402 by Graham Nelson
Minimal Source Text To Reproduce
when play begins:
	let L be { 26199, -16765, -14760, -14253, -7925, -406, 1287, 9165, 10822, 10822, 16644, 21193, 22688, 
24357, 24930, 30329, 31363, -32192, -31033, -24114, -13685, 23718, -22206, 10033, 11093, 31653, -31931, 
-30725, -27122, -25693, -24571, -24571, -24005, -23593, -23356, -21766, -21047, -18126, -18111, -16263, 
-16263, -16263, -16263, -16263, -16263, -16263, -16263, -14760, -7902, -5927, -2365, -2365, -1919, -1020, 
-380, 3650, 4230, 7412, 7502, 10822, 11095, 21773, 26106, -31346, -26954, -14437};
	say "[L].";
	sort L;
	say "[paragraph break]sort: [L].";
	sort L in reverse order;
	say "[paragraph break]rsort: [L].";

Test is a room.
Additional Informationoutput:

26199, -16765, -14760, -14253, -7925, -406, 1287, 9165, 10822, 10822, 16644, 21193, 22688, 24357, 24930, 30329, 31363, -32192, -31033, -24114, -13685, 23718, -22206, 10033, 11093, 31653, -31931, -30725, -27122, -25693, -24571, -24571, -24005, -23593, -23356, -21766, -21047, -18126, -18111, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -14760, -7902, -5927, -2365, -2365, -1919, -1020, -380, 3650, 4230, 7412, 7502, 10822, 11095, 21773, 26106, -31346, -26954 and -14437.

sort: 26199, -23593, -23356, -21766, -21047, -18126, -18111, -16765, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -14760, -14760, -14253, -7925, -7902, -5927, -2365, -2365, -1919, -1020, -406, -380, 1287, 3650, 4230, 7412, 7502, 9165, 10822, 10822, 10822, 11093, 11095, 16644, 21193, 21773, 22688, 23718, 24357, 24930, 26106, 30329, 31363, 31653, -32192, -31931, -31346, -31033, -30725, -27122, -26954, -25693, -24571, -24571, -24114, -24005, -22206, -14437, -13685 and 10033.

rsort: 7502, 7412, 4230, 3650, 1287, -380, -406, -1020, -1919, -2365, -2365, -5927, -7902, -7925, -13685, -14253, -14437, -14760, -14760, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -16263, -16765, -18111, -18126, -21047, -21766, -22206, -23356, -23593, -24005, -24114, -24571, -24571, -25693, -26954, -27122, -30725, -31033, -31346, -31931, -32192, 31653, 31363, 30329, 26199, 26106, 24930, 24357, 23718, 22688, 21773, 21193, 16644, 11095, 11093, 10822, 10822, 10822, 10033 and 9165.
TagsNo tags attached.
Effect(serious/mild) Game compiles but misbehaves
Attached Files

- Relationships

-  Notes
(0001934)
EmacsUser (manager)
2012-12-04 10:28

Confirmed. ListCompareEntries in Lists.i6t uses a subtraction, which can overflow, instead of a conditional:

- - - -
if (cf == 0)
    return i - j;
- - - -

Affects tables and lists of other types also.
(0001938)
zarf (developer)
2012-12-08 21:41

This will of course affect Glulx as well, with much larger numbers.
(0002274)
graham (administrator)
2014-01-12 08:30

Fixed; the subtraction in ListCompareEntries, a foolish economy to save cycles, has been replaced by comparisons.

- Issue History
Date Modified Username Field Change
2012-12-04 05:25 NRTurner New Issue
2012-12-04 10:28 EmacsUser Note Added: 0001934
2012-12-04 10:28 EmacsUser Status new => confirmed
2012-12-08 21:41 zarf Note Added: 0001938
2014-01-12 08:30 graham Note Added: 0002274
2014-01-12 08:30 graham Status confirmed => resolved
2014-01-12 08:30 graham Resolution open => fixed
2014-01-12 08:30 graham Assigned To => graham
2014-05-07 07:34 jmcgrew Fixed in Version => 6L02
2014-05-07 07:34 jmcgrew Status resolved => closed


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker