ebevhan added inline comments.

================
Comment at: lib/AST/ExprConstant.cpp:9501
+      return false;
+    return Success(Result.getInt() >> Scale, E);
+  }
----------------
ebevhan wrote:
> The shift here will not produce the correct rounding behavior for fixed-point 
> to integer conversion. E-C says `Conversions from a fixed-point to an integer 
> type round toward zero.` However, simply shifting will always round towards 
> -inf.
> 
> If the fixed-point number is negative, you need to add `lowBits(Scale)` 
> before performing the shift.
> 
> This operation here is also not the same as the FixedPointToBool emission in 
> CodeGen.
Oops, this has nothing at all to do with FixedPointToBool. Forget about that.


Repository:
  rC Clang

https://reviews.llvm.org/D48456



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to