From: Tulio Ligneul Date: Mon, 21 Aug 2017 00:25:59 +0000 (-0300) Subject: Fixes possible error on "Vector::add(..)". X-Git-Tag: v9.0.0-rc1~1159^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=547602adeb073d6879af4cf5c0097581e5aeaa06;p=dealii.git Fixes possible error on "Vector::add(..)". In "Vector::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. --- diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 505e09967b..9c6bc07716 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1177,7 +1177,7 @@ Vector::add (const std::vector &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::add (const std::vector &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); }