[Trilinos-Users] Some Trilinos compilation warnings

Andrey Prokopenko prok at math.uh.edu
Sat Aug 25 00:11:23 MDT 2012


Hi everyone,

Late at night, nitpicking at Trilinos, i.e. some compilation warnings
that could be potential bugs. Maybe, it is a good idea to include
"-Wall -Wextra" to CXX_FLAGS.


(1) trilinos/packages/zoltan/src/hier/hier.c:1780:43: warning: array
subscript is above array bounds [-Warray-bounds]

seems like an obvious misprint

-    for (i=1; i <= ZOLTAN_HIER_LAST_PLATFORM; i++){
+   for (i=0; i < ZOLTAN_HIER_LAST_PLATFORM; i++) {



(2) trilinos/packages/zoltan/src/rcb/shared.c:2121:7: warning:
‘current_candidate’ may be used uninitialized in this function
[-Wuninitialized]

the code in question does have potentially uninitalized pointer which
is then dereferenced

ZOLTAN_ID_PTR current candidate;
[...]
if (dindx) {
    int prevpart = -1;
    /* there is more than one part on this proc. */
    /* use dindx to access dots grouped by part */
    for (i = 0; i < dotnum; i++) {
      if (dotpt->Part[dindx[i]] != prevpart) {
        /* Assuming dots are grouped according to part number. */
        /* Then candidate is first dot in new part */
        current_candidate = &(gidpt[dindx[i]*num_gid_entries]);
        prevpart = dotpt->Part[dindx[i]];
      }
      ZOLTAN_SET_GID(zz, &(dot_candidates[dindx[i]*num_gid_entries]),
current_candidate);
  }
}


(3) compiling Epetra, EpetraExt, Ifpack and some others with -Wextra
spits out quite a few warning related to virtual inheritance, like

trilinos/packages/epetra/src/Epetra_Time.cpp:60:1: warning: base class
‘class Epetra_Object’ should be explicitly initialized in the copy
constructor [-Wextra]


(4) trilinos/packages/triutils/src/Trilinos_Util_smsrres.cpp:99:27:
warning: ‘scaled_res_norm’ may be used uninitialized in this function
[-Wuninitialized]

Code definitely seems troublesome:

double scaled_res_norm;
[...]
   if (norm_b > 1.0E-7)
      {
       scaled_res_norm = res_norm/sqrt(norm_b);
       printf(    "Scaled two norm of residual = %12.4g\n",scaled_res_norm);
      }
    free((void *) tmp);

    return(scaled_res_norm);



Sincerely,
Andrey




More information about the Trilinos-Users mailing list