From b29f38a428c896be68d3c6ddc4f2f2f31de9d3aa Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Sat, 12 Mar 2016 13:31:46 -0800 Subject: [PATCH] Explain union safety in MicroLock comment Reviewed By: ot Differential Revision: D3045850 fb-gh-sync-id: ee19b146c43410d8d8804c9bfe79c3811394b10e shipit-source-id: ee19b146c43410d8d8804c9bfe79c3811394b10e --- folly/MicroLock.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/folly/MicroLock.h b/folly/MicroLock.h index 07aa40b8..159e3341 100644 --- a/folly/MicroLock.h +++ b/folly/MicroLock.h @@ -43,6 +43,10 @@ namespace folly { * limit yourself to MicroLock slot zero, which will use the two * least-significant bits in the bottom byte. * + * (Note that such a union is safe only because MicroLock is based on + * a character type, and even under a strict interpretation of C++'s + * aliasing rules, character types may alias anything.) + * * MicroLock uses a dirty trick: it actually operates on the full * word-size, word-aligned bit of memory into which it is embedded. * It never modifies bits outside the ones it's defined to modify, but -- 2.34.1