<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>Thanks Richard.</div><div><br>On 28-Nov-2013, at 2:37 am, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br><br></div><div><span></span></div><blockquote type="cite"><div><div dir="ltr">On Wed, Nov 27, 2013 at 8:34 AM, Rahul Jain <span dir="ltr"><<a href="mailto:1989.rahuljain@gmail.com" target="_blank">1989.rahuljain@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Thanks David for your valuable inputs.</div>
</blockquote><div><br></div><div>David provided you with an approximation of the answer a few messages ago:</div><div><br></div><div><div>> 5.3.4p17 states "... If the new expression creates an array of objects of class type, access and ambiguity control are done for the destructor"</div>
</div><div><br></div><div>This wording was somewhat defective, because it didn't deal with the case of a deleted destructor (and also incorrectly suggests that a destructor might be ambiguous). In the latest draft, this wording has been fixed, and it now says:</div>
<div><br></div><div>5.3.4p19: "If the new-expression creates an array of objects of class type, the destructor is potentially invoked (12.4)."</div><div>12.4p11: "A program is ill-formed if a destructor that is potentially invoked is deleted or not accessible from the context of the invocation."<br>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hi Richard,</div>
<div><br></div><div>Any comments on this behaviour??</div><div><br></div><div>Thanks,</div><div>Rahul</div></div><div class=""><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 12:43 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div>On Tue, Nov 26, 2013 at 10:53 AM, Rahul Jain <<a href="mailto:1989.rahuljain@gmail.com" target="_blank">1989.rahuljain@gmail.com</a>> wrote:<br>
> I think I got something relevant: Do these words make any sense in our<br>
> context?<br>
<br>
</div>Not quite<br>
<div><br>
> An allocation or deallocation function<br>
<br>
</div>Allocation/deallocation function does not refer to<br>
constructor/destructor. See 3.4p1:<br>
<br>
"A C++ implementation provides access to, and management of, dynamic<br>
storage via the global allocation functions operator new and operator<br>
new[] and the global deallocation functions operator delete and<br>
operator delete[]."<br>
<br>
These are actually not the ctor/dtor, in 3.4p2 their declarations are shown as:<br>
<br>
void* operator new(std::size_t);<br>
void* operator new[](std::size_t);<br>
void operator delete(void*);<br>
void operator delete[](void*);<br>
<br>
So, roughly, if you say "new T" first operator new(sizeof(T)) is<br>
called, then the ctor for T is called on the returned storage, if the<br>
T ctor throws, then operator delete is called on the storage before<br>
the exception is propagated (that's why even non-array "new T"<br>
odr-uses the deallocation function, operator delete - even though it<br>
doesn't/shouldn't odr-use T's dtor).<br>
<div><br>
> for a class is odr-used by a<br>
> new expression appearing in a potentially-evaluated expression as specified<br>
> in 5.3.4(New) and 12.5(Free store). A deallocation function for a class is<br>
> odr-used by a delete expression appearing in a potentially-evaluated<br>
> expression as specified in 5.3.5(Delete) and 12.5(Free store).<br>
><br>
> What exactly does one mean by saying that something is odr-used?<br>
<br>
</div>The simplistic interpretation is that if something is odr-used it must<br>
be defined (ie: there must be (one) definition). For example:<br>
<br>
void f1();<br>
void f2();<br>
<br>
int main() {<br>
  f1(); // odr use of f1 - the program is ill-formed if 'f1' is not defined<br>
  size_t s = sizeof(f2); // non-odr-use of f2 - the program is valid<br>
even if 'f2' is never defined<br>
}<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>
</div></blockquote></body></html>