ECP-WarpX / WarpX

WarpX is an advanced electromagnetic & electrostatic Particle-In-Cell code.
https://ecp-warpx.github.io
Other
287 stars 183 forks source link

Build Warning in BreitWheelerEngineWrapper #4898

Closed ax3l closed 4 months ago

ax3l commented 4 months ago

I am compiling WarpX in development with Conda-Forge's GCC 12.3.0 using the default options cmake -S . -B build and see this warning:

In file included from /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/string:50,
                 from /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/stdexcept:39,
                 from /home/axel/src/warpx/build/_deps/fetchedamrex-src/Src/Base/AMReX_Exception.H:5,
                 from /home/axel/src/warpx/build/_deps/fetchedamrex-src/Src/Base/AMReX.H:10,
                 from /home/axel/src/warpx/build/_deps/fetchedamrex-src/Src/Base/AMReX_Array.H:5,
                 from /home/axel/src/warpx/build/_deps/fetchedamrex-src/Src/AmrCore/AMReX_AmrMesh.H:5,
                 from /home/axel/src/warpx/build/_deps/fetchedamrex-src/Src/AmrCore/AMReX_AmrCore.H:5,
                 from /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/QedWrapperCommons.H:17,
                 from /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/QedChiFunctions.H:16,
                 from /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.H:12,
                 from /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp:7:
In static member function 'static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = char; bool _IsMove = false]',
    inlined from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const char*; _OI = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_algobase.h:495:30,
    inlined from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const char*; _OI = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_algobase.h:522:42,
    inlined from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = const char*; _OI = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_algobase.h:529:31,
    inlined from '_OI std::copy(_II, _II, _OI) [with _II = const char*; _OI = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_algobase.h:620:7,
    inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const char*; _ForwardIterator = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_uninitialized.h:147:27,
    inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const char*; _ForwardIterator = char*]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_uninitialized.h:185:15,
    inlined from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = const char*; _ForwardIterator = char*; _Tp = char]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_uninitialized.h:372:37,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const char*; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/vector.tcc:775:34,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_insert_dispatch(iterator, _InputIterator, _InputIterator, std::__false_type) [with _InputIterator = const char*; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h:1779:19,
    inlined from 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with _InputIterator = const char*; <template-parameter-2-2> = void; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h:1481:22,
    inlined from 'void picsar::multi_physics::utils::serialization::put_in(T, std::vector<char, std::allocator<char> >&) [with T = int]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/utils/serialization.hpp:34:19,
    inlined from 'std::vector<char, std::allocator<char> > picsar::multi_physics::containers::equispaced_1d_table<RealType, VectorType>::serialize() const [with RealType = double; VectorType = std::vector<double>]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/containers/picsar_tables.hpp:369:41,
    inlined from 'std::vector<char, std::allocator<char> > picsar::multi_physics::phys::breit_wheeler::dndt_lookup_table<RealType, VectorType>::serialize() const [with RealType = double; VectorType = std::vector<double>]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/physics/breit_wheeler/breit_wheeler_engine_tables.hpp:419:22,
    inlined from 'std::vector<char, std::allocator<char> > BreitWheelerEngine::export_lookup_tables_data() const' at /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp:112:51:
/home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_algobase.h:431:30: warning: writing 4 bytes into a region of size 1 [-Wstringop-overflow=]
  431 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/x86_64-conda-linux-gnu/bits/c++allocator.h:33,
                 from /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/allocator.h:46,
                 from /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/string:41:
In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = char]',
    inlined from 'static _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = char]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/alloc_traits.h:464:28,
    inlined from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h:378:33,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const char*; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/vector.tcc:799:40,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_insert_dispatch(iterator, _InputIterator, _InputIterator, std::__false_type) [with _InputIterator = const char*; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h:1779:19,
    inlined from 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with _InputIterator = const char*; <template-parameter-2-2> = void; _Tp = char; _Alloc = std::allocator<char>]' at /home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/stl_vector.h:1481:22,
    inlined from 'void picsar::multi_physics::utils::serialization::put_in(T, std::vector<char, std::allocator<char> >&) [with T = double]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/utils/serialization.hpp:34:19,
    inlined from 'std::vector<char, std::allocator<char> > picsar::multi_physics::containers::equispaced_1d_table<RealType, VectorType>::serialize() const [with RealType = double; VectorType = std::vector<double>]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/containers/picsar_tables.hpp:368:41,
    inlined from 'std::vector<char, std::allocator<char> > picsar::multi_physics::phys::breit_wheeler::dndt_lookup_table<RealType, VectorType>::serialize() const [with RealType = double; VectorType = std::vector<double>]' at /home/axel/src/warpx/build/_deps/fetchedpicsar-src/multi_physics/QED/include/picsar_qed/physics/breit_wheeler/breit_wheeler_engine_tables.hpp:419:22,
    inlined from 'std::vector<char, std::allocator<char> > BreitWheelerEngine::export_lookup_tables_data() const' at /home/axel/src/warpx/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp:112:51:
/home/axel/micromamba/envs/warpx-openmp-dev/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/new_allocator.h:137:55: note: at offset 17 into destination object of size 18 allocated by 'operator new'
  137 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
      |                                                       ^

I am not sure if this is a false positive, but we should investigate.

cc @lucafedeli88 have you seen this before?

WeiqunZhang commented 4 months ago

I looked at the code and I am convinced it's false positive. Also found this. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100366