:issue:`3388`
+Avoid integer overflow when using dispersioncorrection
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+A change in the integer type storing the index meant that the value could overflow
+and turn negative, leading to wrong lookup and unphysical values.
+
+:issue:`3391`
+
Fixes for ``gmx`` tools
^^^^^^^^^^^^^^^^^^^^^^^
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
for (int q = 0; q < (inputrec.efep == efepNO ? 1 : 2); q++)
{
- double csix = 0;
- double ctwelve = 0;
- int npair = 0;
- int nexcl = 0;
+ double csix = 0;
+ double ctwelve = 0;
+ int64_t npair = 0;
+ int64_t nexcl = 0;
if (!EI_TPI(inputrec.eI))
{
numAtomsForDensity_ = mtop.natoms;
{
for (int tpj = tpi; tpj < ntp; tpj++)
{
- const int iCount = typecount[tpi];
- const int jCount = typecount[tpj];
- int npair_ij;
+ const int64_t iCount = typecount[tpi];
+ const int64_t jCount = typecount[tpj];
+ int64_t npair_ij;
if (tpi != tpj)
{
npair_ij = iCount * jCount;
}
if (debug)
{
- fprintf(debug, "Counted %d exclusions\n", nexcl);
+ fprintf(debug, "Counted %" PRId64 " exclusions\n", nexcl);
fprintf(debug, "Average C6 parameter is: %10g\n", csix);
fprintf(debug, "Average C12 parameter is: %10g\n", ctwelve);
}