<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 7, 2014, at 12:46 , David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Mar 7, 2014 at 11:57 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Mar 7, 2014, at 11:32, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><br>On Fri, Mar 7, 2014 at 11:19 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br>Author: jrose<br>Date: Fri Mar  7 13:19:56 2014<br>New Revision: 203273<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203273&view=rev">http://llvm.org/viewvc/llvm-project?rev=203273&view=rev</a><br>Log:<br>[ADT] Update PointerIntPair to handle pointer types with more than 31 bits<br>free.<br><br>Previously, the assertions in PointerIntPair would try to calculate the<br>value<br>(1 << NumLowBitsAvailable); the inferred type here is 'int', so if there<br>were<br>more than 31 bits available we'd get a shift overflow.<br><br><br>I'm guessing this was found by the static analyzer? (how/why? the<br>"bits free" would be an template parameter, not a runtime value - and<br>I assume we never even approach 32 bits free... seems sort of like a<br>false positive?)<br><br>Or do we really have such a pointer somewhere that's aligned to 4 GB?<br><br><br>I bet the analyzer could find it if such a path occurred, but the real<br>answer is much more mundane: I've been working on an internal tool that<br>actually has a Fixnum class like the one in the test case, which was<br>originally just being used in a PointerUnion (alongside a real pointer). I<br>tried using the same Fixnum<31> with a PointerIntPair, and Clang gave me a<br>warning (-Wshift-op-overflow, I think).<br></blockquote><br>Still a little confused - what kind of pointer were you going to fit<br>in the PointerIntPair? (& if you couldn't fit a pointer there, why not<br>just use the int directly and skip the pair)<br></div></blockquote></div><br><div>It's actually</div><div><br></div><div>using Offset = Fixnum<31>;</div><div>using OffsetOrRecord = PointerUnion<Offset, Record *>;</div><div><br></div><div>// added today</div><div>using OffsetAndShouldForce = PointerIntPair<Offset, 1, bool>;</div><div><br></div><div>On a 64-bit system this is the same amount of space as std::pair<Offset, bool>, but on a 32-bit system it fits in 32 bits. *shrug* I guess you're right that I should just bit-mangle it myself.</div><div><br></div><div>Jordan</div><div><br></div></body></html>