]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Initialize a member variable. 3098/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 10 Sep 2016 21:10:09 +0000 (15:10 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 10 Sep 2016 21:10:09 +0000 (15:10 -0600)
This is not strictly necessary, because the variable is later initialized in
constructors of derived classes, but the patch avoids copying uninitialized
variables when copying around objects of type FiniteElementData. (There are
cases when we pass around these objects, without actually using derived
classes; but in those cases, the flag appears to be unused.

include/deal.II/fe/fe_base.h
source/fe/fe_data.cc

index 471766078f6865c5cea7494fa77fb8f2e1f42787..c52019fa30ce35c6f47ef47a2e7fb3e28c01b72e 100644 (file)
@@ -419,7 +419,8 @@ public:
    * then this is always the case.
    *
    * Since this is an extremely common operation, the result is cached in the
-   * #cached_primitivity variable which is computed in the constructor.
+   * #cached_primitivity variable which is computed in the constructor of the
+   * derived class FiniteElement.
    */
   bool is_primitive () const;
 
index 7eae662ddae16e0d6af01b637c75051c88a12267..672cf849309885d8a9bd0b80bc404e1b0da16391 100644 (file)
@@ -61,7 +61,12 @@ FiniteElementData (const std::vector<unsigned int> &dofs_per_object,
                      ?
                      BlockIndices(1, dofs_per_cell)
                      :
-                     block_indices)
+                     block_indices),
+  // the following field is only set in the FiniteElement
+  // constructor by calling set_primitivity() of this base
+  // class. however, to ensure that we always have boolean
+  // values, initialize it with the safe choice
+  cached_primitivity (false)
 {
   Assert(dofs_per_object.size()==dim+1, ExcDimensionMismatch(dofs_per_object.size()-1,dim));
 }

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.