Hi,
The background here is that I made a trial implementation of P1494r4 -
std::observable() - and want to produce testcases.
—— so …..
I am looking for either examples where GCC produces time-travel optimisation
(or alternately some evidence that these are not expected).
(In case someone is not familiar with the time-travel analogy) a simple example
from P1494:
void b(int &r, int *p) {
if (!p) std::fprintf(stderr, "count: %d\n", ++r);
if (!p) std::fprintf(stderr, "p is null\n");
*p += r; // p may be assumed non-null
}
Since dereferencing p is UB, the compiler may assume that p is non-null - and
therefore elide the check(s) before (thus time-travel).
In practice, (at least on the platform I am testing on) GCC trunk does not do
this - it does reorder code to eliminate the second null test - but it still
prints both sets of output.
TIA
Iain