While trying to write a class that times the duration between calling it\'s constructor and destructor, I ran into what I think is a bug in clang. (Edit: it\'s not a bug; it
Short answer: due to NRVO, the output of the program may be either 0
or the actual duration. Both are valid.
For background, see first:
Guideline:
For example, when we see the following pattern:
T f() {
T ret;
A a(ret); // or similar
return ret;
}
We need to ask ourselves: does A::~A()
modify our return value somehow? If yes, then our program most likely has a bug.
For example: