[llvm-dev] [EXTERNAL] Re: bug is APFloat assignment

Davis, Alan via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 16 12:42:48 PDT 2018


Sorry, I abbreviated the "test case" a little too much.

APF2 is actually defined separately. And it's in a union, which avoids the issue that there is no APFloat(void). So it's something like:

union U {
  U() {}
  ~U() {}
  APFloat APF2;
} u;

int main(int argc, char **argv) {
  APFloat APF1(APFloat::IEEEdouble());
  u.APF2 = APF1;
  u.APF2.print(dbgs());
}

So this is a little more nuanced than I thought. I think the design is that it should not be possible to construct an APFloat without semantics, and this union thing circumvents that. I still think it's a bug, but fairly easy to avoid: either properly construct APF2, or avoid assignment.

-Alan

From: Friedman, Eli [mailto:efriedma at codeaurora.org]
Sent: Tuesday, October 16, 2018 1:35 PM
To: Davis, Alan; llvm-dev at lists.llvm.org
Subject: [EXTERNAL] Re: [llvm-dev] bug is APFloat assignment

On 10/16/2018 11:21 AM, Davis, Alan via llvm-dev wrote:
I am getting a segfault when assigning one APFloat to another, as in:

APFloat APF1(APFloat::IEEEdouble());
APFloat APF2 = APF1;

Just tried it; seems to work fine.


APFloat is a wrapper class that wraps either an IEEEFloat or a DoubleAPFloat. A union called Storage in APFloat contains the underlying object, which is one of those two types. The assignment APF2 = APF1

What assignment?  "APFloat APF2 = APF1;" calls the copy constructor, not the assignment operator.

-Eli

--

Employee of Qualcomm Innovation Center, Inc.

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181016/eccbdbba/attachment.html>


More information about the llvm-dev mailing list