From be26124797332e0763c7592854f2ff199cfb2819 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 26 Nov 2018 07:49:35 +0100 Subject: [PATCH] Be clear about Inner::kind being deliberate UB (#236) --- src/bytes.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bytes.rs b/src/bytes.rs index 3d6fb31..d7071d7 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -2429,6 +2429,10 @@ impl Inner { // bits, so even without any explicit atomic operations, reading the // flag will be correct. // + // This is undefind behavior due to a data race, but experimental + // evidence shows that it works in practice (discussion: + // https://internals.rust-lang.org/t/bit-wise-reasoning-for-atomic-accesses/8853). + // // This function is very critical performance wise as it is called for // every operation. Performing an atomic load would mess with the // compiler's ability to optimize. Simple benchmarks show up to a 10%