Project

General

Profile

Bug #2329

compiler warning with gcc 4.8

Added by Szilárd Páll about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
simple
Close

Description

/home/pszilard/projects/gromacs/gromacs-master/src/gromacs/awh/read-params.cpp: In function ‘void gmx::setStateDependentAwhParams(gmx::AwhParams*, const pull_params_t*, pull_t*, const real (*)[3], int, const t_grpopts*, warninp_t)’:
/home/pszilard/projects/gromacs/gromacs-master/src/gromacs/awh/read-params.cpp:631:54: warning: ‘m_pullvec’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                 if ((n != m) && (n == m_pullvec || m == m_pullvec) && box[m][n] > 0)
                                                      ^
/home/pszilard/projects/gromacs/gromacs-master/src/gromacs/awh/read-params.cpp:608:13: note: ‘m_pullvec’ was declared here
         int m_pullvec, count_nonzeros = 0;
             ^

Mixed precision build using:

$ /usr/bin/g++-4.8 --version 
g++-4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

Associated revisions

Revision 9b0f5b40 (diff)
Added by Aleksei Iupinov about 2 years ago

Provide dummy initialization to silence a warning

Either the real value is set in the loop below, or the program terminates.

Fixes #2329

Change-Id: Iefa89e1e1ad6d454befd461ea650e7f3bb79904c

History

#1 Updated by Szilárd Páll about 2 years ago

I do not fully understand the (pcrd_params->vec[m] != 0) condition around the initialization of m_pullvec, but given that it's conditionally initialized it does not seem like a false positive, does it?

#2 Updated by Paul Bauer about 2 years ago

I wouldn't say this is something that could happen in a real case. The code will never reach line 631 if it did not pass the conditional above at 613 where the variable becomes initialized. Any case where the conditional is skipped for all cases would be caught by the next conditional at line 619. Still might be better to initialize it when declaring and setting it to something meaningless in my opinion. Also, for some reason this does not show up when I build the code with 4.8.5, guess I used the wrong flags

#3 Updated by Gerrit Code Review Bot about 2 years ago

Gerrit received a related patchset '1' for Issue #2329.
Uploader: Aleksei Iupinov ()
Change-Id: gromacs~release-2018~Iefa89e1e1ad6d454befd461ea650e7f3bb79904c
Gerrit URL: https://gerrit.gromacs.org/7296

#4 Updated by Szilárd Páll about 2 years ago

  • Target version set to 2018-beta2

#5 Updated by Szilárd Páll about 2 years ago

  • Status changed from New to Resolved

#7 Updated by Erik Lindahl about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF