Giter Site home page Giter Site logo

Comments (5)

Midar avatar Midar commented on May 13, 2024

Oh wow, this is bad. And while there is a test for __block, it is not thorough enough to catch this. Let me debug this and improve on the test.

from objfw.

Midar avatar Midar commented on May 13, 2024

Fixed.

from objfw.

GunGraveKoga avatar GunGraveKoga commented on May 13, 2024

One more problem I found.
Two different blocks, that's capture single __block variable, does not share value of that variable.
We have variable __block int i = 2;
If first block do some thing like this i--;
In the second block variable "i" is still equal 2

from objfw.

Midar avatar Midar commented on May 13, 2024

I cannot reproduce this. Can you check your on the latest version? There were two commits to fix this, maybe you only checked out the first?

The following code works for me:

#import <ObjFW/ObjFW.h>

typedef void (^voidblock)(void);

static OFArray*
test()
{
    __block double d = 0;
    voidblock block1 = Block_copy(^ {
        d++;
    });
    voidblock block2 = Block_copy(^ {
        of_log(@"%f", d);
    });
    return @[block1, block2];
}

int
main()
{
    OFArray <voidblock> *t = test();

    t[0]();
    t[1]();

    return 0;
}

from objfw.

GunGraveKoga avatar GunGraveKoga commented on May 13, 2024

Yes, it's work for now.
Tested build with latest changes.
Thanks.

from objfw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.