<div dir="ltr">Have added these assertions in r272515.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 2, 2016 at 10:42 PM, Dylan McKay <span dir="ltr"><<a href="mailto:dylanmckay34@gmail.com" target="_blank">dylanmckay34@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><p style="margin:0px 0px 1.2em!important">I will be writing the code that calls this. The method bodies are extracted verbatim from <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">isIntN</code>, which is used exclusively in in-tree MC/backend code. This would’ve silently overflowed in any of the 34 occurrences of this function in-tree.</p><span class="">
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important">Probably best to return the correct result for N==64 and then (if appropriate) error out for N<1 and N>64</p>
</blockquote>
</span><p style="margin:0px 0px 1.2em!important">I agree, I’ll add this in. Let’s hope it doesn’t bring out any latent bugs.</p>
<div title="MDH:SSB3aWxsIGJlIHdyaXRpbmcgdGhlIGNvZGUgdGhhdCBjYWxscyB0aGlzLiBUaGUgbWV0aG9kIGJv
ZGllcyBhcmUgZXh0cmFjdGVkIHZlcmJhdGltIGZyb20gYGlzSW50TmAsIHdoaWNoIGlzIHVzZWQg
ZXhjbHVzaXZlbHkgaW4gaW4tdHJlZSBNQy9iYWNrZW5kIGNvZGUuIFRoaXMgd291bGQndmUgc2ls
ZW50bHkgb3ZlcmZsb3dlZCBpbiBhbnkgb2YgdGhlIDM0IG9jY3VycmVuY2VzIG9mIHRoaXMgZnVu
Y3Rpb24gaW4tdHJlZS48ZGl2Pjxicj48L2Rpdj48ZGl2PiZndDsmbmJzcDs8c3BhbiBzdHlsZT0i
Zm9udC1zaXplOiAxMi44cHg7Ij5Qcm9iYWJseSBiZXN0IHRvIHJldHVybiB0aGUgY29ycmVjdCBy
ZXN1bHQgZm9yIE49PTY0IGFuZCB0aGVuIChpZiBhcHByb3ByaWF0ZSkgZXJyb3Igb3V0IGZvciBO
Jmx0OzEgYW5kIE4mZ3Q7NjQ8L3NwYW4+PC9kaXY+PGRpdj48c3BhbiBzdHlsZT0iZm9udC1zaXpl
OiAxMi44cHg7Ij48YnI+PC9zcGFuPjwvZGl2PjxkaXY+PHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTog
MTIuOHB4OyI+SSBhZ3JlZSwgSSdsbCBhZGQgdGhpcyBpbi4gTGV0J3MgaG9wZSBpdCBkb2Vzbid0
IGJyaW5nIG91dCBhbnkgbGF0ZW50IGJ1Z3MuPC9zcGFuPjwvZGl2Pg==" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 2, 2016 at 10:36 PM, John Regehr <span dir="ltr"><<a href="mailto:regehr@cs.utah.edu" target="_blank">regehr@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure in what circumstances these functions are used.  It is often very bad manners to throw assertions from library code.  But if you are writing the code that calls this code, then an assertion definitely sounds appropriate.<br>
<br>
Probably best to return the correct result for N==64 and then (if appropriate) error out for N<1 and N>64.<span><font color="#888888"><br>
<br>
John</font></span><span><br>
<br>
<br>
On 6/2/16 12:32 PM, Dylan McKay wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
How do you think this should be handled? Assertion error?<br>
<br>
On Thu, Jun 2, 2016 at 10:10 PM, John Regehr <<a href="mailto:regehr@cs.utah.edu" target="_blank">regehr@cs.utah.edu</a><br></span><span>
<mailto:<a href="mailto:regehr@cs.utah.edu" target="_blank">regehr@cs.utah.edu</a>>> wrote:<br>
<br>
         /// Gets the maximum value for a N-bit unsigned integer.<br>
        -inline uint64_t maxUIntN(uint64_t N) { return UINT64_C(1) << N; }<br>
        +inline uint64_t maxUIntN(uint64_t N) { return (UINT64_C(1) <<<br>
        N) - 1; }<br>
<br>
<br>
    This is still wrong unless N is guaranteed to be no greater than 63.<br>
<br>
    John<br>
<br>
<br>
</span></blockquote>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>