]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix compiler warning 2087/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 20 Jan 2016 16:55:19 +0000 (17:55 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 20 Jan 2016 16:57:26 +0000 (17:57 +0100)
source/multigrid/mg_transfer_matrix_free.cc

index 8bb7c5992f875063bb5f1509ed1b8b308ca4abfd..da97e205cd21cf8c0dd0d521d7c4f68fb814a48f 100644 (file)
@@ -719,19 +719,21 @@ namespace
                              VectorizedArray<Number> *data)
   {
     Assert(degree > 0, ExcNotImplemented());
-    const unsigned int loop_length = 2*degree+1;
+    const int loop_length = 2*degree+1;
     unsigned int degree_to_3 [loop_length];
     degree_to_3[0] = 0;
-    for (unsigned int i=1; i<loop_length-1; ++i)
+    for (int i=1; i<loop_length-1; ++i)
       degree_to_3[i] = 1;
     degree_to_3[loop_length-1] = 2;
     for (unsigned int c=0; c<n_components; ++c)
-      for (unsigned int k=0; k<(dim>2 ? loop_length : 1); ++k)
-        for (unsigned int j=0; j<(dim>1 ? loop_length : 1); ++j)
+      for (int k=0; k<(dim>2 ? loop_length : 1); ++k)
+        for (int j=0; j<(dim>1 ? loop_length : 1); ++j)
           {
             const unsigned int shift = 9*degree_to_3[k] + 3*degree_to_3[j];
             data[0] *= weights[shift];
-            for (unsigned int i=1; i<loop_length-1; ++i)
+            // loop bound as int avoids compiler warnings in case loop_length
+            // == 1 (polynomial degree 0)
+            for (int i=1; i<loop_length-1; ++i)
               data[i] *= weights[shift+1];
             data[loop_length-1] *= weights[shift+2];
             data += loop_length;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.