[PATCH] [compiler-rt] Avoid undefined behaviour in __floatsisf and __floatsidf
Stephen Canon via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 13:53:42 PST 2015
Yes, you’re right. Of course, as we have people using compiler-rt with other compilers (and contributing patches to support them), we should also avoid implementation-defined behavior when it’s not ridiculously burdensome to do so.
– Steve
> On Nov 2, 2015, at 4:50 PM, Tim Northover <t.p.northover at gmail.com> wrote:
>
> 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