Swift code crashes when overflowing integers

Originator:kusterer
Number:rdar://22949590 Date Originated:02-Oct-2015 05:10 PM
Status:Open Resolved:
Product:Developer Tools Product Version:2.0
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Do the following in Terminal:

ulimac:~ uli$ swift
Welcome to Apple Swift version 2.0 (700.0.59 700.0.72). Type :help for assistance.
  1> var result : UInt8 = 255;
result: UInt8 = 255
  2> result += 2
Execution interrupted. Enter Swift code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)

That second-to-last line indicates the program crashed. I fully support making overflows a hard error instead of just letting them happen in a programming language, but I would have expected it to terminate more gracefully, e.g. with an "integer overflow exception" or something like that. At the least there should be an error message, not just an interruption.

NB - This also crashes in regular compiled Swift code, not just in the REPL.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!