Skip to content

Commit 0aa91f4

Browse files
committed
Add a _fixLifetime to stdlib/Set.swift test.
On Linux with -O: [ RUN ] Set.formSymmetricDifference stdout>>> check failed at /Users/docker_user/src/build/buildbot_linux/swift-linux-x86_64/main.swift, line 3245 stdout>>> unexpected value: "94788628116752" (of type Swift.Int) [ FAIL ] Set.formSymmetricDifference The test is roughly: var s1 = Set(...) let s1_copy = s1 let identity1 = s1._rawIdentifier() s1.someMutatingMethod1() check(s1) check(s1_copy) s1.someMutatingMethod2() // Mutating the set should cause an identity change releaseAssert(identity1 != s1._rawIdentifier()) On Linux, the optimizer is able to destroy s1_copy before the call to s1.someMutatingMethod2(), which generates new Set storage. This new storage uses the same address as the destroyed s1_copy. Fixes rdar://72933150 ([CanonicalOSSA] Fix Set.swift unit test that assumes object lifetime)
1 parent d25ce3d commit 0aa91f4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

validation-test/stdlib/Set.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,11 @@ SetTestSuite.test("formSymmetricDifference")
32423242

32433243
// Removing all elements should cause an identity change
32443244
expectNotEqual(identity1, s1._rawIdentifier())
3245+
3246+
// Without a fixLifetime here, the (non-ObjC) optimizer destroys
3247+
// 's1' after its last uses and recycles the storage so the identity
3248+
// check above fails.
3249+
_fixLifetime(s1_copy)
32453250
}
32463251

32473252
SetTestSuite.test("removeFirst") {

0 commit comments

Comments
 (0)