[Bug tree-optimization/105327] Bogus use-after-free warning new in GCC 12
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105327 --- Comment #2 from Andrew Pinski --- Switching around the order to do: g.p_ = 0; P p (new (v) T); Fixes the warning and I think correctly.
[Bug tree-optimization/105327] Bogus use-after-free warning new in GCC 12
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105327 --- Comment #1 from Andrew Pinski --- I don't think this is a bogus one. std::shared_ptr owns the pointer once it is passed, not before. So when you do: mem_guard g (v); ... P p (new (v) T); ... the constructor of p might cause operator