The attached screen shot says it all: I have a valid true Bool, I negate it with the bang operator, and (Xcode tells me) I have an invalid value.
It appears that this "invalid" value does behave as if it were false. But really, wtf?
The attached screen shot says it all: I have a valid true Bool, I negate it with the bang operator, and (Xcode tells me) I have an invalid value.
It appears that this "invalid" value does behave as if it were false. But really, wtf?
I've had this issue in Xcode 8.3.1 and Swift 3.1 https://github.com/onmyway133/notes/issues/278
I tried
But does not work. The workaround is to
let enabled = disable ? false : true
I'm no LLVM expert but I wouldn't be surprised about this behavior at all, unless optimization is set to Onone
in which case it should have left your code alone. The intermediate variable is just asking to be optimized away, after all.
debug
config (with Onone
) is default, but not necessary. –
Stoical Got the same issue, with correct value for add code like print(theBoolValue)
.
But when use p
in swift command line. Or just check the value in debug stack, the value become <invalid>(Oxfe)
.
© 2022 - 2024 — McMap. All rights reserved.
Bool
are0x01
(true
) and0x00
(false
) – Honestyenabled
value can't be optimized out since it is used on line 73. However, this could just be an Xcode debugger bug... – SonorityadFreeButton.isEnabled = !PurchaseState.isAdfree
– Honestyenabled
be optimized away even if it's used? Can't it just get replaced, depending on the optimization level? – Stoical