Skip to content

Commit

Permalink
[tmva] Fix new warning in TMVA with gcc 13.2
Browse files Browse the repository at this point in the history
When compiling with gcc 13.2, there is a new warning in TMVA that is
fixed by this commit:

```c++
In static member function ‘static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = long unsigned int; _Up = long unsigned int; bool _IsMove = true]’,
    inlined from ‘constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:506:30,
    inlined from ‘constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:533:42,
    inlined from ‘constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:540:31,
    inlined from ‘constexpr _OI std::copy(_II, _II, _OI) [with _II = move_iterator<long unsigned int*>; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:633:7,
    inlined from ‘static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<long unsigned int*>; _ForwardIterator = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:147:27,
    inlined from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<long unsigned int*>; _ForwardIterator = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:185:15,
    inlined from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = move_iterator<long unsigned int*>; _ForwardIterator = long unsigned int*; _Tp = long unsigned int]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:373:37,
    inlined from ‘constexpr _ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = long unsigned int*; _ForwardIterator = long unsigned int*; _Allocator = allocator<long unsigned int>]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:399:2,
    inlined from ‘constexpr void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const long unsigned int*; _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>]’ at /usr/include/c++/13.2.1/bits/vector.tcc:819:9,
    inlined from ‘constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>]’ at /usr/include/c++/13.2.1/bits/stl_vector.h:1411:17,
    inlined from ‘void TMVA::MethodDL::ParseInputLayout()’ at /home/rembserj/spaces/master/root/src/root/tmva/tmva/src/MethodDL.cxx:470:24:
/usr/include/c++/13.2.1/bits/stl_algobase.h:437:30: error: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ forming offset 32 is out of the bounds [0, 32] [-Werror=array-bounds=]
  437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |
```

The fix suggested in this commit is to directly assign from a full
initializer list, which is also more readable in the code.
  • Loading branch information
guitargeek committed Dec 18, 2023
1 parent 1ef255f commit 6ac991d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tmva/tmva/src/MethodDL.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ void MethodDL::ParseInputLayout()
// when we will support 3D convolutions we would need to add extra 1's
if (inputShape.size() == 2) {
// case of dense layer where only width is specified
inputShape.insert(inputShape.begin() + 1, {1,1});
inputShape = {inputShape[0], 1, 1, inputShape[1]};
}
else if (inputShape.size() == 3) {
//e.g. case of RNN T,W -> T,1,W
inputShape.insert(inputShape.begin() + 2, 1);
inputShape = {inputShape[0], inputShape[1], 1, inputShape[2]};
}

this->SetInputShape(inputShape);
Expand Down

0 comments on commit 6ac991d

Please sign in to comment.