]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tensor<k, dim, Number::unroll(): fix copy statement 16519/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 22 Jan 2024 20:14:25 +0000 (14:14 -0600)
committerMatthias Maier <tamiko@43-1.org>
Mon, 22 Jan 2024 20:16:31 +0000 (14:16 -0600)
The task for the rank-1 case is to copy all values from the internal
values array to the iterator range, so let us just use
```
  std::copy(std::begin(values), std::end(values), begin);
```
for this. The problem with the `&values[dim]` statement is the fact that
values[dim] is an out-of-bounds access and the address of if is
undefined.

include/deal.II/base/tensor.h

index cd96cb7a5e1c300055d5ad63d2158aa695c6e928..bc75a71ab0e4b5f626cc1d68e122e8f3033d217d 100644 (file)
@@ -1872,7 +1872,7 @@ Tensor<rank_, dim, Number>::unroll(const Iterator begin,
              ExcMessage(
                "The provided iterator range must contain at least 'dim' "
                "elements."));
-      std::copy(&values[0], &values[dim], begin);
+      std::copy(std::begin(values), std::end(values), begin);
     }
 }
 

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.