[llvm-commits] [llvm] r80907 - /llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp

Daniel Dunbar daniel at zuster.org
Thu Sep 3 01:08:06 PDT 2009


On Thu, Sep 3, 2009 at 12:53 AM, Andreas Neustifter<astifter-llvm at gmx.at> wrote:
> Hi,
>
> thank you very much for investigating this!
>
> Daniel Dunbar wrote:
>> -  if (weight != (unsigned)MissingValue) {
>> +  if (weight != ~0U) {
>
> Since allmost all my other development takes place on platforms that do
> not even support floating point my float-typecasting knowledge is a bit
> rusty.
>
> If you have time: can you explain why this is necessary and why the cast
> from double to unsigned does not work? (At least not on all platforms...)

I didn't know this off the top of my head either, but the relevant
language for C99 (I presume C++ is similar is):
--
6.3.1.4p1: When a finite value of real floating type is converted to
an integer type other than _Bool, the fractional part is discarded
(i.e., the value is truncated toward zero). If the value of the
integral part cannot be represented by the integer type, the behavior
is undefined.
--

 - Daniel




More information about the llvm-commits mailing list