Item 17: Store newed Objects in Smart Pointers in Standalone Statements
Because the evaluation order of function designator, arguments, and subexpression within arguments is unspecified.
This statement
bar(std::shared_ptr(new Foo), baz());…could be evaluated in this order:
new Foobaz()std::shared_ptr(...)bar(...)
And if baz() throws an exception, the newed Foo object is leaked.
