-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#47286
Copy link
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsnumericsArea → standard library: Numeric APIArea → standard library: Numeric APIoperatorsFeature: operatorsFeature: operatorsregressionswift 4.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Previous ID | SR-4864 |
Radar | rdar://problem/32149641 |
Original Reporter | @weissi |
Type | Bug |
Status | Resolved |
Resolution | Duplicate |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, 4.0Regression, TypeChecker |
Assignee | @weissi |
Priority | Medium |
md5: e3dcd3e211ea39b44ad3038337af8a18
blocks:
- SR-4709 SRP source breakage: error: expression was too complex
Issue Description:
in the latest Swift 4 snapshot, this program
private extension UInt32 {
/* this takes an UInt32 in big-endian representation and converts it to
whatever endianness the we're running on. It does work for both big
and little endian machines.
Cf. https://commandcenter.blogspot.co.uk/2012/04/byte-order-fallacy.html
*/
static func from(bigEndian input: UInt32) -> UInt32 {
var val: UInt32 = input
return withUnsafePointer(to: &val) { (ptr: UnsafePointer<UInt32>) -> UInt32 in
return ptr.withMemoryRebound(to: UInt8.self, capacity: 4) { data in
return (UInt32(data[3]) << 0) | (UInt32(data[2]) << 8) | (UInt32(data[1]) << 16) | (UInt32(data[0]) << 24)
}
}
}
}
let x = UInt32.from(bigEndian: 17)
print(x)
fails to compile with
$ /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-09-a.xctoolchain/usr/bin/swiftc test.swift
test.swift:9:16: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
return withUnsafePointer(to: &val) { (ptr: UnsafePointer<UInt32>) -> UInt32 in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
but is just fine in Swift 3.1 release.
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsnumericsArea → standard library: Numeric APIArea → standard library: Numeric APIoperatorsFeature: operatorsFeature: operatorsregressionswift 4.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis