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-5699] Non escaping blocks should not need to malloc captured values (stack memory pointers are just fine) #48269

Open
phausler opened this issue Aug 16, 2017 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@phausler
Copy link
Member

Previous ID SR-5699
Radar None
Original Reporter @phausler
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 3c11791d099a492f95fad8536f56b7ce

relates to:

Issue Description:

given the following code:

func fooauto(_ apply: @autoclosure () -> UInt16) {
    if apply() == 4 {
        fatalError()
    }
}

func foononatuo(_ apply: () -> UInt16) {
    if apply() == 4 {
        fatalError()
    }
}

func fooregular(_ value: UInt16) {
    if value == 4 {
        fatalError()
    }
}

func test1() {
    var f: UInt16 = 10
    fooregular(f)
    f = 4
}

func test2() {
    var f: UInt16 = 10
    fooauto(f)
    f = 4
}

func test3() {
    var f: UInt16 = 10
    foononatuo {
        return f
    }
    f = 4
}

I would expect none of them to ever call malloc in release mode

test2 and 3 currently do

@belkadan
Copy link
Contributor

We haven't done anything special with non-escaping closures yet (partly) because we haven't implemented the checking for withoutActuallyEscaping.

@jckarter, is there a bug for this already?

@jckarter
Copy link
Member

This might fall under @atrick's umbrella for fixing the closure ABI, SR-5441.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants