In a Swift playground I wrote this line, for which the result will in most cases overflow:
var ran = UInt8(arc4random())
I do realize a more appropriate method would be to mask off the lower bits, or take a mod, but that's irrelevant to my question. What happens is that rather than there being an error noting the overflow (at least a warning?), the system attempts to run the code and produces an EXC_BAD_INSTRUCTION error. Am I overlooking something or is this a bug in the semantic analysis performed by Swift?
This is using Xcode version 7.0.1
(Later edit: this question differs from a similar one in that it's a simpler context (store only, not an arithmetic operation) for which there is no operator such as &+ to indicate the overflow is permissible. The answer posted is, however, comprehensive and for which thanks!)