Skip to content

Conversation

@Cstandardlib
Copy link
Collaborator

Description

Compile warning:

In file included from /abacus-develop/source/source_hamilt/module_vdw/vdwd2.cpp:7:
In member function ‘void vdw::Vdwd2::index_loops(F&&) [with F = vdw::Vdwd2::cal_force()::<lambda(double, double, double, double, int, int, const ModuleBase::Vector3<double>&, const ModuleBase::Vector3<double>&)>&]’,
    inlined from ‘virtual void vdw::Vdwd2::cal_force()’ at /abacus-develop/source/source_hamilt/module_vdw/vdwd2.cpp:58:16:
/abacus-develop/source/source_hamilt/module_vdw/vdwd2.h:39:9: warning: iteration 2147483646 invokes undefined behavior [-Waggressive-loop-optimizations]
   39 |         for (int it1 = 0; it1 != ucell_.ntype; ++it1)
      |         ^~~
/abacus-develop/source/source_hamilt/module_vdw/vdwd2.h:39:31: note: within this loop
   39 |         for (int it1 = 0; it1 != ucell_.ntype; ++it1)
      |                           ~~~~^~~~~~~~~~~~~~~

What's changed?

  • Change the for loop boundary check from != to <, now no warning popped.

@Cstandardlib Cstandardlib added the Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS label Jan 20, 2026
@mohanchen mohanchen merged commit b497e7b into deepmodeling:develop Jan 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants