It is undefined behavior to access an object that has been moved. It is
also not possible to "move back" an object.
In this particular case with the recent changes to ThreadLocalStorage
and AffineConstraints we run into an exception:
constraints_move.debug: ../nptl/pthread_mutex_lock.c:117: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
(The move operation destroys the mutex and accessing it afterwards
when we try to move back results in a crash.)
AffineConstraints<double> cm(std::move(constraints));
cm.print(deallog.get_file_stream());
- deallog << constraints.n_constraints() << std::endl << std::endl;
-
- constraints = std::move(cm);
- constraints.print(deallog.get_file_stream());
- deallog << cm.n_constraints() << std::endl;
deallog << "OK" << std::endl;
}
- 1 = 0.0
- 2 = 1.0
- 3 = 2.0
- 5 = 3.0
- 8 = 4.0
- 13 = 5.0
- 21 = 6.0
+ 1 = 0
+ 2 = 1.00000
+ 3 = 2.00000
+ 5 = 3.00000
+ 8 = 4.00000
+ 13 = 5.00000
+ 21 = 6.00000
DEAL::
- 1 = 0.0
- 2 = 1.0
- 3 = 2.0
- 5 = 3.0
- 8 = 4.0
- 13 = 5.0
- 21 = 6.0
-DEAL::0
-DEAL::
- 1 = 0.0
- 2 = 1.0
- 3 = 2.0
- 5 = 3.0
- 8 = 4.0
- 13 = 5.0
- 21 = 6.0
-DEAL::0
+ 1 = 0
+ 2 = 1.00000
+ 3 = 2.00000
+ 5 = 3.00000
+ 8 = 4.00000
+ 13 = 5.00000
+ 21 = 6.00000
DEAL::OK
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