<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 5/13/13 10:21 AM, Manuel Klimek
wrote:<br>
</div>
<blockquote
cite="mid:CAOsfVvkDKSJWk+ugWY5FAVFVS1EY=LzsmYv4y0rAOYqbDYxWNQ@mail.gmail.com"
type="cite">
<div dir="ltr">+richard smith, who proposed to implement it this
way
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, May 13, 2013 at 6:08 PM,
Shuxin Yang <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:shuxin.llvm@gmail.com" target="_blank">shuxin.llvm@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> I'm afraid this
change is going to open a big can of worms. You are
essentially promote <br>
private member function to be public. Such practice
should be generally avoided even for <br>
the local/private class which is used in small scope,
let alone these fundamental structures <br>
which are extensively used in the compiler. <br>
<div> <br>
> object needs the destructor called after its
memory was freed <br>
<br>
</div>
If the block of memory containing APFloat/APInt is
already freed, how do you know <br>
the state of these objects are still valid? Depending on
the implementation, free-operation <br>
might clobber the memory with some special value for
debugging purpose. If it were safe<br>
to call needsCleanup(), why not directly call the
destructor? Is needsCleanup() sufficient <br>
and/or necessary condition for calling the destructor?
How do we keep them in sync in the <br>
future?<br>
</div>
</blockquote>
<div><br>
</div>
<div style="">APFloat/APInt is placement new'ed in the code
in question, and thus we need to call the destructors of
any objects that do memory allocation themselves. We can
save those destructor calls otherwise.</div>
</div>
</div>
</div>
</blockquote>
I understand that if you place a non-plain-old-data in a union, you
have to construct it via placement new, <br>
and explicitly destruct it. I come across similar problem when I
implement unsafe fadd/fsub optimization <br>
half year ago. <br>
<br>
My questions are : <br>
- why do you need to call function xyz() before calling the
destructor. <br>
- if the memory is already freed, why do you know it is safe to
call syz(). <br>
The object may not in valid state. <br>
<br>
</body>
</html>