aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2019-11-20 17:31:23 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2019-11-20 17:31:23 +0100
commitc79b6ffe1fcf8c12005942a1268f79b7d6ecf700 (patch)
treea09f23755e7189015be477fd9c28dc0062aa7c43 /doc
parente78ed6e7f3d64f06761446d0a8dcb356a0373bff (diff)
Add an explicit example for auto and re-evaluation
Diffstat (limited to 'doc')
-rw-r--r--doc/Pitfalls.dox12
1 files changed, 11 insertions, 1 deletions
diff --git a/doc/Pitfalls.dox b/doc/Pitfalls.dox
index 18ced6ea7..6760ce6d2 100644
--- a/doc/Pitfalls.dox
+++ b/doc/Pitfalls.dox
@@ -40,7 +40,17 @@ for(...) { ... w = C * v; ...}
In this example, the type of C is not a \c MatrixXd but an abstract expression representing a matrix product and storing references to \c A and \c B.
Therefore, the product of \c A*B will be carried out multiple times, once per iteration of the for loop.
-Moreover, if the coefficients of A or B change during the iteration, then C will evaluate to different values.
+Moreover, if the coefficients of `A` or `B` change during the iteration, then `C` will evaluate to different values as in the following example:
+
+\code
+MatrixXd A = ..., B = ...;
+auto C = A*B;
+MatrixXd R1 = C;
+A = ...;
+MatrixXd R2 = C;
+\endcode
+for which we end up with `R1` &ne; `R2`.
+
Here is another example leading to a segfault:
\code