[SR-12483] Weak variables deallocated too quickly in optimised (-O) builds #54923
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
modifiers
Feature: Declaration and type modifiers
not a bug
Resolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer error
optimized only
Flag: An issue whose reproduction requires optimized compilation
reference ownership
Feature → modifiers: Reference storage ownership modifiers
swift 5.2
unexpected behavior
Bug: Unexpected behavior or incorrect output
weak
Feature → modifiers → reference ownership: Weak
Environment
Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
Target: x86_64-apple-darwin19.4.0
Additional Detail from JIRA
md5: b87ad1b64715ab96b0b6f6b5dfcfb1c2
Issue Description:
I noticed some strange errors in my iOS project when it was built for release in Swift 5.2, and I was eventually able to create a small test case. It seems that weak variables are deallocated too quickly (or at the very least, they have different semantics between optimised and unoptimised builds). The following produces a different output depending on optimisation:
Interestingly, as annotated above, the declaration and the assignment have to be on different lines to replicate. The non-optimised build operates how I expect, the optimised build does not.
The text was updated successfully, but these errors were encountered: