iceoryx
iceoryx copied to clipboard
Issues with function_ref
Required information
Operating system: Any
Compiler version: Any
Eclipse iceoryx version: master
Observed result or behaviour:
In cxx::function_ref
:
-
operator()
is markednoexcept
- Construction erroneously accepts rvalue capturing lambdas (i.e.
[&] { ... }
) - Construction invokes UB when accepting rvalue non-capturing lambdas (i.e.
[] { ... }
)
Expected result or behaviour:
-
operator()
should not be markednoexcept
, since it is unreasonable for the program to terminate if the user-code invoked throws an exception. - Capturing lambdas necessarily imply state, and it is a mistake that
function_ref
can be built with stateful rvalues. Attempting this construction should result in a compilation error. - Non-capturing lambdas should be okay for construction, since they are convertible to a function pointer. However, the current implementation still saves them as objects, and applies
callable_object(args...)
on them wherecallable_object
is now necessarily a dangling reference.