<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thank you!<div class="">-Joe</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 15, 2016, at 12:04 PM, Joel Gerber <<a href="mailto:joel@grrbrr.ca" class="">joel@grrbrr.ca</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I did a <a href="http://bugreport.apple.com/" class="">bugreport.apple.com</a> one (26448395). I just created another on <a href="http://bugs.swift.org/" class="">bugs.swift.org</a> (SR-743). And yes, in debug mode, no error at all, release mode, error.<br class=""><div class="">
<div style="font-family: Helvetica; font-size: 12px; 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;" class=""><br class="Apple-interchange-newline">Joel Gerber</div><div style="font-family: Helvetica; font-size: 12px; 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;" class=""><a href="mailto:joel@grrbrr.ca" class="">joel@grrbrr.ca</a></div><div style="font-family: Helvetica; font-size: 12px; 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;" class=""><br class=""></div><br class="Apple-interchange-newline">
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 15, 2016, at 1:17 PM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">If you're seeing different diagnostic behavior in debug and release modes, that's a bug. If you have time, please file this on <a href="http://bugs.swift.org/" class="">bugs.swift.org</a> for us to take a look. Thanks!<br class=""><br class="">-Joe<br class=""><br class=""><blockquote type="cite" class="">On Feb 13, 2016, at 11:11 AM, Joel Gerber via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class=""><br class="">I have code that is giving the "shift amount is greater than or equal to type size in bits” error when built in release mode but doesn’t in debug mode. I’m trying to understand all of the various causes of this error in order to better understand what’s happening.<br class=""><br class="">Here’s a dumbed down version of the code that illustrates the issue:<br class=""><br class="">/// Skeleton for actual UInt128 structure.<br class="">struct UInt128 {<br class=""> let value: (upperBits: UInt64, lowerBits: UInt64) = (0, 0)<br class="">}<br class="">/// Shifts `lhs`' bits left by `rhs` bits and returns the result.<br class="">public func <<(lhs: UInt128, rhs: UInt128) -> UInt128 {<br class=""> if rhs.value.upperBits > 0 || rhs.value.lowerBits > 128 {<br class=""> return UInt128(0)<br class=""> }<br class=""> switch rhs {<br class=""> case 0: return lhs // Do nothing shift.<br class=""> case 1...63:<br class=""> let upperBits = (lhs.value.upperBits << rhs.value.lowerBits) + (lhs.value.lowerBits >> (64 - rhs.value.lowerBits))<br class=""> let lowerBits = lhs.value.lowerBits << rhs.value.lowerBits<br class=""> return UInt128(upperBits: upperBits, lowerBits: lowerBits)<br class=""> case 64:<br class=""> // Shift 64 means move lower bits to upper bits.<br class=""> return UInt128(upperBits: lhs.value.lowerBits, lowerBits: 0)<br class=""> case 65...127:<br class=""> // This causes a "shift amount is greater than or equal to type size in bits" error<br class=""> // on release build but not debug build.<br class=""> let upperBits = lhs.value.lowerBits << (rhs.value.lowerBits - 64)<br class=""> return UInt128(upperBits: upperBits, lowerBits: 0)<br class=""> default: return UInt128(0)<br class=""> }<br class="">}<br class=""><br class="">I’ve walked through the Swift code, and while I see some things that might be flagging this error, I’m having a hard time understanding what the underlying causes are.<br class=""><br class="">Joel Gerber<br class=""><a href="mailto:joel@grrbrr.ca" class="">joel@grrbrr.ca</a><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></body></html>