示例工程 24-performance-instruments

24-performance-instruments/Diagnostics/PreconditionRemoved.swift

swift · 0.4 KB

// 演示 -Ounchecked 会移除 precondition:默认构建会终止,-Ounchecked 继续执行。
// 复现:
//   swiftc Diagnostics/PreconditionRemoved.swift -o /tmp/pre && /tmp/pre
//   swiftc -Ounchecked Diagnostics/PreconditionRemoved.swift -o /tmp/pre-unchecked && /tmp/pre-unchecked
let value = 1
precondition(value > 1, "precondition failed")
print("continued with value \(value)")