[cfe-dev] Clang-Cl - Representation of NAN

Bruce Hoult via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 5 01:19:17 PST 2019


C# can handle NaN correctly. It is important NOT to do "if (foo ===
double.Nan)" but instead "if(double.IsNan(foo))". C# code that
compares with double.NaN is simply buggy.

Arithmetic should work correctly in any case.

On Tue, Feb 5, 2019 at 12:29 AM Gaier, Bjoern via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hello everyone,
>
>
>
> we are currently using clang-cl (build with LLVM7) in our project, which previously used the MSVC2017 compiler. We noticed a major difference with the representation of the NAN value.
>
> Clang generates 0x7FF8000000000000 for an NAN
>
> MSVC  generates 0xFFF8000000000000 for an NAN
>
>
>
> This difference leads to problems with C#, because it interacts with our C++ code and 'misses' the NAN.
>
>
>
> Is there a way to change the representation of the NAN via a compiler flag?
>
> Could we also change the source code of clang to force this representation of NAL? Or is this to much effort for a workaround?
>
>
>
> Kind greetings
>
> Björn
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list