[cfe-dev] Fixed point and floating point comparision

Gousemoodhin Nadaf via cfe-dev cfe-dev at lists.llvm.org
Sun Jul 5 12:34:55 PDT 2020


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>
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> on behalf of
> Gousemoodhin Nadaf via cfe-dev <cfe-dev at lists.llvm.org>
> *Sent:* Saturday, June 13, 2020 6:22 AM
> *To:* cfe-dev at lists.llvm.org <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/20200705/c67f4e8d/attachment.html>


More information about the cfe-dev mailing list