From: Andy Dougherty Date: Mon, 8 Apr 2002 13:20:39 +0000 (-0400) Subject: Re: lib/sort.t failure -- real PATCH enclosed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78210658cae7b303c01be2599b05071639c1f618;p=p5sagit%2Fp5-mst-13.2.git Re: lib/sort.t failure -- real PATCH enclosed Message-Id: p4raw-id: //depot/perl@15811 --- diff --git a/lib/sort.t b/lib/sort.t index 52d1d8b..fbeaacf 100644 --- a/lib/sort.t +++ b/lib/sort.t @@ -124,11 +124,8 @@ sub main { $status = checkequal(\@sorted, $unsorted); is($status, '', "contents ok for size $ts"); } - # P5P: The following test (#58) has been observed failing on - # a solaris 2.8 platform. Failure doesn't mean that sort is - # misbehaving, it is just exhibiting an exceedingly unlikely - # pattern of breaking ties. If you see no other failures, - # it should be perfectly safe to install. + # If the following test (#58) fails, see the comments in pp_sort.c + # for Perl_sortsv(). if ($expect_unstable) { ok($unstable_num > 0, 'Instability ok'); } diff --git a/pp_sort.c b/pp_sort.c index aca65d3..af4d7f5 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1376,6 +1376,8 @@ Sort an array. Here is an example: sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); +See lib/sort.pm for details about controlling the sorting algorithm. + =cut */ @@ -1387,15 +1389,18 @@ Perl_sortsv(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) SV **hintsvp; I32 hints; - if ((hints = SORTHINTS(hintsvp))) { - if (hints & HINT_SORT_QUICKSORT) - sortsvp = S_qsortsv; - else { - if (hints & HINT_SORT_MERGESORT) - sortsvp = S_mergesortsv; - else - sortsvp = S_mergesortsv; - } + /* Sun's Compiler (cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2) used + to miscompile this function under optimization -O. If you get test + errors related to picking the correct sort() function, try recompiling + this file without optimiziation. -- A.D. 4/2002. + */ + hints = SORTHINTS(hintsvp); + if (hints & HINT_SORT_QUICKSORT) { + sortsvp = S_qsortsv; + } + else { + /* The default as of 5.8.0 is mergesort */ + sortsvp = S_mergesortsv; } sortsvp(aTHX_ array, nmemb, cmp);