[PATCH] [compiler-rt] Avoid undefined behaviour in __floatsisf and __floatsidf

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 13:50:15 PST 2015


On 2 November 2015 at 04:05, Stephen Canon via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>         3. implicit convert back to signed in (UB because -INT_MIN cannot be represented as int).

I think this is actually implementation-defined: C99 6.3.1.3p3
"Otherwise, if the new type is signed and the value cannot be
represented in it; either the result is implementation-defined or an
implementation-defined signal is raised.".

> The approach that I suggested before avoids this problem by having the result type of the absolute value operation be unsigned.

That looks like it'd work too, of course.

Cheers.

Tim.


More information about the llvm-commits mailing list