Skip to content

Commit 34ed37c

Browse files
committed
Fix debug assert.
1 parent b580dd3 commit 34ed37c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/alloc/src/sync.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ impl<T> Arc<T> {
497497
let inner = init_ptr.as_ptr();
498498
ptr::write(ptr::addr_of_mut!((*inner).data), data);
499499

500+
debug_assert!(
501+
(*inner).strong.load(Relaxed) & STRONG_DROPPED != 0,
502+
"No prior strong references should exist"
503+
);
504+
500505
// The above write to the data field must be visible to any threads which
501506
// observe a non-zero strong count. Therefore we need at least "Release" ordering
502507
// in order to synchronize with the `compare_exchange_weak` in `Weak::upgrade`.
@@ -509,11 +514,6 @@ impl<T> Arc<T> {
509514
//
510515
// These side effects do not impact us in any way, and no other side effects are
511516
// possible with safe code alone.
512-
debug_assert_eq!(
513-
(*inner).strong.load(Relaxed),
514-
1,
515-
"No prior strong references should exist"
516-
);
517517
(*inner).strong.store(ONE_STRONG_WITH_WEAK, Release);
518518

519519
Arc::from_inner(init_ptr)

0 commit comments

Comments
 (0)