Skip to content

gcc12: Fix false positives for std::vector::operator=()#1824

Merged
ax3l merged 1 commit intoopenPMD:devfrom
franzpoeschel:fix-gcc12-false-positives
Dec 18, 2025
Merged

gcc12: Fix false positives for std::vector::operator=()#1824
ax3l merged 1 commit intoopenPMD:devfrom
franzpoeschel:fix-gcc12-false-positives

Conversation

@franzpoeschel
Copy link
Copy Markdown
Contributor

see overload 3, the use is actually correct
https://en.cppreference.com/w/cpp/container/vector/operator=.html

First seen by @ax3l:

    inlined from 'static openPMD::Iteration::BeginStepStatus openPMD::Iteration::beginStep(std::optional<openPMD::Iteration>, openPMD::Series&, bool)' at /home/runner/work/warpx/warpx/build/_deps/fetchedopenpmd-src/src/Iteration.cpp:866:42:
/usr/include/c++/12/bits/stl_algobase.h:434:30: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' reading between 9 and 9223372036854775807 bytes from a region of size 8 [-Werror=stringop-overread]
  434 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/warpx/warpx/build/_deps/fetchedopenpmd-src/src/Iteration.cpp: In static member function 'static openPMD::Iteration::BeginStepStatus openPMD::Iteration::beginStep(std::optional<openPMD::Iteration>, openPMD::Series&, bool)':
/home/runner/work/warpx/warpx/build/_deps/fetchedopenpmd-src/src/Iteration.cpp:866:42: note: at offset [0, 7] into source object '<anonymous>' of size 8
  866 |         res.iterationsInOpenedStep = {idx};
      |      

Note: I still get one false positive from pybind11, but can't do anything about that as it is not our code:

In function '__copy_m',
    inlined from '__copy_move_a2' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_algobase.h:501:30,
    inlined from '__copy_move_a1' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_algobase.h:528:42,
    inlined from '__copy_move_a' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_algobase.h:535:31,
    inlined from 'copy' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_algobase.h:626:7,
    inlined from '__uninit_copy' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_uninitialized.h:147:27,
    inlined from 'uninitialized_copy' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_uninitialized.h:185:15,
    inlined from '__uninitialized_copy_a' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_uninitialized.h:372:37,
    inlined from '_M_assign_aux' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/vector.tcc:339:35,
    inlined from 'operator=' at /nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_vector.h:787:21,
    inlined from 'operator()' at /home/franzpoeschel/build/gcc12/_deps/fetchedpybind11-src/include/pybind11/pybind11.h:1385:75,
    inlined from 'with_internals' at /home/franzpoeschel/build/gcc12/_deps/fetchedpybind11-src/include/pybind11/detail/internals.h:643:14,
    inlined from 'initialize' at /home/franzpoeschel/build/gcc12/_deps/fetchedpybind11-src/include/pybind11/pybind11.h:1377:23:
/nix/store/yhflz90n3xdxkzqxljmhp16rryg9w4cp-gcc-12.4.0/include/c++/12.4.0/bits/stl_algobase.h:434:30: warning: '__builtin_memcpy' reading between 9 and 9223372036854775807 bytes from a region of size 8 [-Wstringop-overread]
  434 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |                              ^
/home/franzpoeschel/build/gcc12/_deps/fetchedpybind11-src/include/pybind11/pybind11.h: In member function 'initialize':
/home/franzpoeschel/build/gcc12/_deps/fetchedpybind11-src/include/pybind11/pybind11.h:1385:75: note: at offset [0, 7] into source object '<anonymous>' of size 8
 1385 |             internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo};
      |                                                                           ^

@franzpoeschel franzpoeschel added this to the 0.17.0 milestone Dec 18, 2025
@franzpoeschel franzpoeschel requested a review from ax3l December 18, 2025 14:09
@ax3l ax3l added the warning label Dec 18, 2025
@ax3l ax3l mentioned this pull request Dec 18, 2025
1 task
Copy link
Copy Markdown
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works! :)
Thanks a lot!

@ax3l ax3l enabled auto-merge (squash) December 18, 2025 14:40
@ax3l ax3l merged commit 6e2ace5 into openPMD:dev Dec 18, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants