[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Swift: overflow raises an error
- From: Jay Carlson <nop@...>
- Date: Thu, 12 Jun 2014 19:24:49 -0400
Apple's programming language Swift is defined to raise an error on integer overflow:
"Unlike arithmetic operators in C, arithmetic operators in Swift do not overflow by default. Overflow behavior is trapped and reported as an error. To opt in to overflow behavior, use Swift’s second set of arithmetic operators that overflow by default, such as the overflow addition operator (&+). All of these overflow operators begin with an ampersand (&)."
I wonder how much Apple's security experience shaped this feature. I also wonder if people are disabling it via the "-Ofast" compiler switch...
In any case, it's a notable exception in language design to "ints shall behave like C"--whatever that really means, anyway. :-)