ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.03k stars 390 forks source link

Library fails to compile with gcc14 #605

Open colbysparks opened 1 month ago

colbysparks commented 1 month ago

Compiling a simple program which includes rx-includes.hpp fails with gcc 14.

#include <iostream>
#include "rxcpp/rx-includes.hpp"

int main() {
    std::cout << "wow" << std::endl;
    return 0;
}

The issue appears to be that the assignment operators of on_next_notification and on_error_notification attempt to modify a private const field here and here, respectively. Apparently this compiles in older versions of gcc because it was simply not attempting to check assignments inside of templates, unless the templates are being used. With this change in gcc 14 however, simple assignments are now checked even inside of templates. This would be my guess as to why this code now fails to compile.

The fix seems to be to simply delete the assignment operator for on_next_notification and on_error_notification, as the two structs are only ever instantiated as shared_ptr so it is not needed. In any case, compilation will fail with older versions of gcc if a user writes code which causes a variant of the assignment operator template to be generated.

Edit: The project I've been working on uses RxCpp v4.1.1, but apparently the const declaration of the T value field of on_next_notification has been removed on master.