Swift Protobuf中的错误消息CocoaPods
问题描述:
我已经安装了一个叫做'SwiftProtobuf'的Cocoapod,但是它出现了这个错误'Integer literal'9223372036854775808'当存储到'Int'时溢出错误发生在这个函数中:Swift Protobuf中的错误消息CocoaPods
if n >= 0x8000000000000000 { // -Int64.min
if n > 0x8000000000000000 {
这里的整体功能:
internal mutating func nextSInt() throws -> Int64 {
if p == end {
throw TextFormatDecodingError.malformedNumber
}
let c = p[0]
if c == asciiMinus { // -
p += 1
// character after '-' must be digit
let digit = p[0]
if digit < asciiZero || digit > asciiNine {
throw TextFormatDecodingError.malformedNumber
}
let n = try nextUInt()
if n >= 0x8000000000000000 { // -Int64.min
if n > 0x8000000000000000 {
// Too large negative number
throw TextFormatDecodingError.malformedNumber
} else {
return Int64.min // Special case for Int64.min
}
}
return -Int64(bitPattern: n)
} else {
let n = try nextUInt()
if n > UInt64(bitPattern: Int64.max) {
throw TextFormatDecodingError.malformedNumber
}
return Int64(bitPattern: n)
}
}
答
我曾经为0xffffffff作为作为UInt32的和错误走了。