]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixes possible error on "Vector<Number>::add(..)".
authorTulio Ligneul <tulio@petrosoftdesign.com>
Mon, 21 Aug 2017 00:25:59 +0000 (21:25 -0300)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 27 Aug 2017 23:31:35 +0000 (19:31 -0400)
In "Vector<Number>::add(..)", a pointer to the first element of the
std::vectors was gotten, for instance, by &indices[0], which implies
that the first element of the vector exists. Therefore, if an empty
vector was used, while this works on gcc, this would result in a crash
when using Visual Studio. In this case, the pointer should be gotten by
std::vector::data(). This fix changes de former by the latter access form.

include/deal.II/lac/vector.h

index 505e09967be7f40c4b8afd2336eb3383b96ab02c..9c6bc07716bf3f44de073001e15776d304dc412a 100644 (file)
@@ -1177,7 +1177,7 @@ Vector<Number>::add (const std::vector<size_type> &indices,
 {
   Assert (indices.size() == values.size(),
           ExcDimensionMismatch(indices.size(), values.size()));
-  add (indices.size(), &indices[0], &values[0]);
+  add (indices.size(), indices.data(), values.data());
 }
 
 
@@ -1191,7 +1191,7 @@ Vector<Number>::add (const std::vector<size_type> &indices,
 {
   Assert (indices.size() == values.size(),
           ExcDimensionMismatch(indices.size(), values.size()));
-  add (indices.size(), &indices[0], values.val);
+  add (indices.size(), indices.data(), values.val);
 }
 
 

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.