Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13112] assignment to enum instance should deinitialize associated values on all optimization levels #55558

Closed
tayloraswift opened this issue Jun 29, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-13112
Radar None
Original Reporter @Kelvin13
Type Bug
Status Resolved
Resolution Invalid
Environment

$ swift --version
Swift version 5.2-dev (LLVM 4cd92ac, Swift 79716ef)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 43a01c2ae7a5e2ac494c04e32d0d72d5

Issue Description:

currently, the following test program prints `false` on normal settings, and `true` when compiled with `-O`

related discussion: https://forums.swift.org/t/why-isn-t-isuniquelyreferenced-working-here/37949/4?u=taylorswift

final
class C 
{
    init() 
    {
    }
}
enum E
{
    case empty 
    case c(C)
}

func foo()  
{
    var e:E = .c(.init())
    switch e 
    {
    case .c(var c):
        e = .empty
        print(isKnownUniquelyReferenced(&c))
    default:
        break
    }
}

foo()
@rjmccall
Copy link
Member

I'm going to close this one; it's acceptable for `isKnownUniquelyReferenced` to change from `false` to `true` under optimization as a general matter. Whether `switch` should guarantee to not separately keep the switch value alive in unoptimized builds is better tracked as SE-13114.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants