• msvc wrt locking errors...

    From Chris M. Thomasson@3:633/280.2 to All on Tue Feb 6 18:10:23 2024
    This is not giving me a warning, but an assertion. I am still wondering
    why Bonita has to suppress all of those warnings wrt this thread ala MSVC:

    https://groups.google.com/g/comp.lang.c++/c/pFsb3JI11-k

    Here is some bugged code I just created, wrt MSVC version 17.8.5. No
    warnings, but an assertion:

    https://i.ibb.co/QQFyZQq/image.png

    code:
    ____________________________________
    #include <iostream>
    #include <functional>
    #include <thread>
    #include <mutex>


    namespace ct
    {
    struct mutex_test
    {
    std::mutex m_mutex;

    void
    works()
    {
    m_mutex.lock();
    m_mutex.unlock();
    }


    void
    foobar()
    {
    m_mutex.lock();
    //m_mutex.unlock(); YIKES!
    }
    };
    }


    int
    main()
    {
    std::cout << "ct_threads... ;^)\n" << std::endl;

    {
    ct::mutex_test test;

    test.works();
    test.foobar(); // humm... Kabboom!
    }

    return 0;
    }
    ____________________________________


    Btw, I am going to port my new XCHG based code from Relacy race detector
    into actual C++ code where we all can play with it. Getting to a point
    where I need to use it for a project.

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)
  • From Chris M. Thomasson@3:633/280.2 to All on Tue Feb 6 19:33:57 2024
    On 2/5/2024 11:10 PM, Chris M. Thomasson wrote:
    This is not giving me a warning, but an assertion. I am still wondering
    why Bonita has to suppress all of those warnings wrt this thread ala MSVC:

    https://groups.google.com/g/comp.lang.c++/c/pFsb3JI11-k
    [...]

    Sometime tomorrow I can work on this. I need to compile the bugged test
    code with the warning level bumped up.


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)
  • From Chris M. Thomasson@3:633/280.2 to All on Thu Feb 8 07:47:40 2024
    On 2/5/2024 11:10 PM, Chris M. Thomasson wrote:
    This is not giving me a warning, but an assertion. I am still wondering
    why Bonita has to suppress all of those warnings wrt this thread ala MSVC:

    https://groups.google.com/g/comp.lang.c++/c/pFsb3JI11-k
    [...]

    Okay, made some progress. Here is a little example of where the warnings
    pop up. "Sketchy" use of std::unique_lock, well, imvvho that is: ___________________________________________
    #include <iostream>
    #include <functional>
    #include <thread>
    #include <mutex>
    #include <cassert>


    namespace ct
    {
    struct mutex_test
    {
    std::mutex m_mutex;

    void
    bar(std::unique_lock<std::mutex>& lock)
    {
    assert(lock);
    lock.unlock();
    }

    void
    foo()
    {
    std::unique_lock<std::mutex> lock(m_mutex);

    // lock will be unlocked after this call!
    bar(lock);

    lock.lock(); // Yup...
    }
    };
    }


    int
    main()
    {
    std::cout << "ct_threads... ;^)\n" << std::endl;

    {
    ct::mutex_test test;

    test.foo();
    }

    return 0;
    }
    ___________________________________________


    Interesting wrt MSVC.

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)