Yes, the memory allocated for the CFoo object will be freed in this case.
Because the exception due to distribution failure causes the CFoo constructor to fail, the new expression guarantees the free memory allocated for this CFoo .
This warranty is specified in 5.3.4 [expr.new] / 17 ISO / IEC 14882: 2003.
Please note that it is always advisable to assign a dynamic highlight result to a smart pointer to ensure proper cleaning. For example, if another code appeared in the CFoo constructor, and this caused an exception, then the CBar object that was already successfully assigned earlier in the constructor would be leaked.
source share