KDAB/KDBindings

Property move constructor cannot promise noexcept

jm4R opened this issue · 2 comments

jm4R commented

The move constructor of Property is marked noexcept, but - as long as it emmits public moved signal - it can throw from any slot. Simple example:

TEST_CASE("Nothrow move")
{
    try {
        std::set_terminate([] {
            std::cerr << "TERMINATED" << std::endl;
        });
        Property<int> p;
        p.moved().connect([&] { throw 0; });

        Property<int> p2 = std::move(p);
    } catch (int) {
    }
}

The program will call std::terminate as it throws from noexcept function.

Hi @jm4R , thanks for noticing and reporting this.
I've opened #25 which removes the noexcept promise.

jm4R commented

@LeonMatthesKDAB personally I would make moved signal private (at library scope) and keep the promise unless it is somehow required to be public. I see that bindings needs this signal to track the property address but I am not aware of any other use case. But it's your decision here.