[SR-2512] Switch case statement over integer value used to return enum cases leads to compiler crash, if optimization is enabled. #45117
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
optimized only
Flag: An issue whose reproduction requires optimized compilation
Environment
Operating System: Mac OS X 10.11.6 (15G31),
Xcode Version 8.0 beta 6 (8S201h),
Swift version 3.0 (swiftlang-800.0.43.6 clang-800.0.38)
Additional Detail from JIRA
md5: 7da33622778ac949894c52edd31db090
Issue Description:
When using a switch case statement over an integer value to return values of an enum, the compiler crashes, if two cases have the same condition and optimization is enabled.
The issue was observed with the following code example:
The issue was observed, if the switch was performed over a integer value (unsigned and signed; 8, 16, 32 and 64 bit), but not with other values (String, Float, etc.)
The issue was also observed with RawRepresentable enums.
When using other return types (Strings, OptionSet values, Integer values, Enums with associated values), this issue was not reproducible.
The compiler was invoked with the following command:
where Demo.swift was the file containing only the above swift code.
The compiler crashed with the warning
In Xcode, this error was not visible and the compilation just failed (Error: swiftc failed with exit code 1).
The text was updated successfully, but these errors were encountered: