Consider the following line of code:
new (p++) T();
If the constructor T() throws an exception, is p guaranteed to have already been incremented?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From 5.3.4 [expr.new] (quoting from n3242):
So in a new expression the allocation function is used from a function call (which makes sense). All allocation functions are functions, including the ones provided by the implementation, from 3.7.4.1 [basic.stc.dynamic.allocation]:
So by the time an exception is thrown from the constructor, the allocation has taken place and the associated function call expression has been fully evaluated.