From 547602adeb073d6879af4cf5c0097581e5aeaa06 Mon Sep 17 00:00:00 2001 From: Tulio Ligneul Date: Sun, 20 Aug 2017 21:25:59 -0300 Subject: [PATCH] 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. --- include/deal.II/lac/vector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.39.5