From: Daniel Colascione Date: Sat, 12 Mar 2016 21:31:46 +0000 (-0800) Subject: Explain union safety in MicroLock comment X-Git-Tag: 2016.07.26~447 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b29f38a428c896be68d3c6ddc4f2f2f31de9d3aa;p=folly.git Explain union safety in MicroLock comment Reviewed By: ot Differential Revision: D3045850 fb-gh-sync-id: ee19b146c43410d8d8804c9bfe79c3811394b10e shipit-source-id: ee19b146c43410d8d8804c9bfe79c3811394b10e --- 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