BUG: Fix warnings and possible UB in `VariadicInputsImageFilter::SetInputsImpl`
Summary
Avoid returning a temporary value from the function.
Rationale
Spotted on Debian Testing with GCC 9.2.1:
/otb/Modules/Core/Functor/include/otbVariadicInputsImageFilter.h: In instantiation of 'auto otb::VariadicInputsImageFilter<TOuptut, TInputs>::SetInputsImpl(Tuple&, std::index_sequence<Is ...>) [with Tuple = std::tuple<otb::VectorImage<float, 2>*>; long unsigned int ...Is = {0}; TOuptut = otb::VectorImage<float, 2>; TInputs = {otb::VectorImage<float, 2>}; std::index_sequence<Is ...> = std::integer_sequence<long unsigned int, 0>]':
/otb/Modules/Core/Functor/include/otbVariadicInputsImageFilter.h:125:5: required from 'void otb::VariadicInputsImageFilter<TOuptut, TInputs>::SetInputs(TInputs* ...) [with TOuptut = otb::VectorImage<float, 2>; TInputs = {otb::VectorImage<float, 2>}]'
/otb/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx:260:46: required from here
/otb/Modules/Core/Functor/include/otbVariadicInputsImageFilter.h:148:91: warning: returning temporary initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime]
148 | return std::initializer_list<int>{(this->template SetInput<Is>(std::get<Is>(t)), 0)...};
| ^
Copyright
The copyright owner is Laurențiu Nicola (CS ROMANIA) and has signed the ORFEO ToolBox Contributor License Agreement.
Check before merging:
- All discussions are resolved
- At least 2
👍 votes from core developers, no👎 vote. - The feature branch is (reasonably) up-to-date with the base branch
- Dashboard is green
- Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
- Optionally, run
git diff develop... -U0 --no-color | clang-format-diff.py -p1 -i
on latest changes and commit
Edited by Laurențiu Nicola