From df29fc33a89c6531a6644cf14002a39e642420e6 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Thu, 8 Jun 2023 23:53:34 +0100 Subject: [PATCH] [cxx-interop] Make a test work properly with optimizations The compiler might optimize away the first copy, so just make sure that no copies are happening during the actual initialization of Array. rdar://110422053 --- .../stdlib/overlay/custom-convertible-to-collection.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/Interop/Cxx/stdlib/overlay/custom-convertible-to-collection.swift b/test/Interop/Cxx/stdlib/overlay/custom-convertible-to-collection.swift index bc77cacf78cab..7a3b5db9c8d01 100644 --- a/test/Interop/Cxx/stdlib/overlay/custom-convertible-to-collection.swift +++ b/test/Interop/Cxx/stdlib/overlay/custom-convertible-to-collection.swift @@ -20,13 +20,9 @@ CxxSequenceTestSuite.test("SimpleCopyAwareSequence to Swift.Array") { copiesCount = 0 let seq = SimpleCopyAwareSequence() - - let seqCopy = seq - expectEqual(1, copiesCount) // make sure our copy tracking mechanism works - let array = Array(seq) - expectEqual(1, copiesCount) // make sure we don't copy the C++ sequence value unnecessarily + expectEqual(0, copiesCount) // make sure we don't copy the C++ sequence value unnecessarily } #endif