[cfe-dev] Fixed point and floating point comparision

Bevin Hansson via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 6 01:36:09 PDT 2020


Hi,

I’m afraid I don’t agree with your interpretation. The spec says “The rounding of conversions […] is unspecified”, not that the conversions themselves are.

Floating-to-fixed point conversions just aren’t implemented yet, which is why it crashes. The support is still a bit experimental. I agree that it should not crash, though.

I will leave some comments in the patch.

/ Bevin

From: Gousemoodhin Nadaf <nadafgouse5 at gmail.com>
Sent: July 05, 2020 9:35 PM
To: Bevin Hansson <bevin.hansson at ericsson.com>
Cc: cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] Fixed point and floating point comparision

Hello Bevin,
As per N1169 4.1.4 (Type conversion, usual arithmetic conversions), conversions between the fixed point and floating point is unspecified. I believe before looking/checking for conversions, we have to handle unsupported conversions, if the conversion is not possible, we have to return NULL.

Let me know your opinions.

Second patch updated: Changed word from "Comparision" to "Conversion", "Conversion" is correct word to describe. This verified on the local build, it does not lead to a compiler crash.

Regards,
Nadaf.

On Tue, Jun 16, 2020 at 5:17 AM Bevin Hansson <bevin.hansson at ericsson.com<mailto:bevin.hansson at ericsson.com>> wrote:
Hi Gousemoodhin,

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

/ Bevin

________________________________
From: cfe-dev <cfe-dev-bounces at lists.llvm.org<mailto:cfe-dev-bounces at lists.llvm.org>> on behalf of Gousemoodhin Nadaf via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
Sent: Saturday, June 13, 2020 6:22 AM
To: cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org> <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
Subject: [cfe-dev] Fixed point and floating point comparision

Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }

please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200706/d2dfd85a/attachment-0001.html>


More information about the cfe-dev mailing list