eclipse-iceoryx / eclipse-iceoryx/iceoryx
Issues with function_ref
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 492
- Avg merge
- 18h 57m
- Merged PRs (30d)
- 1
Description
## Required information
**Operating system:**
Any
**Compiler version:**
Any
**Eclipse iceoryx version:**
master
**Observed result or behaviour:**
In `cxx::function_ref`:
1. `operator()` is marked `noexcept`
2. Construction erroneously accepts rvalue capturing lambdas (i.e. `[&] { ... }`)
3. Construction invokes UB when accepting rvalue non-capturing lambdas (i.e. `[] { ... }`)
**Expected result or behaviour:**
1. `operator()` should not be marked `noexcept`, since it is unreasonable for the program to terminate if the user-code invoked throws an exception.
2. 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.
3. 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 where `callable_object` is now necessarily a dangling reference.
Contributor guide
Research direction
Start by locating the cxx::function_ref implementation and its construction and call operators. Compare the behavior with the three expected results: throwing user code must not be forced into noexcept, capturing rvalue lambdas must be rejected, and non-capturing lambdas must remain valid; finish by checking the relevant behavior with the project's existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100