swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.59k stars 10.36k forks source link

[SR-8682] Sort doesn't work correctly in recent master #51196

Open 56ed3025-6cad-4bf8-b972-9c308205a0af opened 6 years ago

56ed3025-6cad-4bf8-b972-9c308205a0af commented 6 years ago
Previous ID SR-8682
Radar rdar://problem/44099288
Original Reporter @palimondo
Type Bug

Attachment: Download

Environment Swift \`master\` September 1st.
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler, Standard Library | |Labels | Bug, 5.0Regression | |Assignee | None | |Priority | Medium | md5: 95127a31654eb1c96497beda220fecf6

Issue Description:

The attached reduced test case shows that sorting [Int] doesn't work in recent master.

How wasn't this caught by validation tests?! It looks like the array has to have a certain size for this to manifest itself?

Issue wan't reproducible on Xcode Beta 6 from 13th of August. Binary search for the onset of the problem with swift-DEVELOPMENT snapshots points to introduction of the issue between 16th of 18th of August.

56ed3025-6cad-4bf8-b972-9c308205a0af commented 6 years ago

I'd suspect some of these PRs.

56ed3025-6cad-4bf8-b972-9c308205a0af commented 6 years ago

cc overlazy (JIRA User), @airspeedswift

hamishknight commented 6 years ago

Another example:

let a = [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4]
print(a.sorted())
// [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4]
//                               ~~~
belkadan commented 6 years ago

@swift-ci create

ee21ea02-9d7a-4385-8c3c-ad21e8e490a8 commented 6 years ago

Fixed in https://github.com/apple/swift/pull/19107/

xwu commented 3 years ago

@palimondo Should this bug be closed?