Michael Layzell wrote:

In summary, the nsRefPtr is copied into a temporary in its side of the 
conditional. The nullptr is cast to a struct Foo*, which is constructed into a 
nsRefPtr, which is bound to a temporary, and then moved around a bit between 
temporaries. The resulting temporary xvalue then has the raw pointer extracted 
from it (which uses the rvalue-reference cast call - the part which is causing 
the problem), which is stored locally after the temporaries are destroyed. The 
temporaries which are created in the conditional are then destroyed, which 
causes a Release(), but that is OK because there was an AddRef due to the extra 
copy in the nsRefPtr branch.

So the ternary actually causes an unnecessary AddRef/Release pair, neat.

"Neat" as in "Can we please have a static analysis to detect this please"?

--
Warning: May contain traces of nuts.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to