64 to 32 truncation warnings for ints and floats?

Hi all,

In C & C++, Apple's gcc 4.2 produces 2 warnings for this code with -
Wshorten-64-to-32:

int main(int,char**)
{
  double d = 1.0;
  float f = d; // warning: 64 to 32
  
  long s1 = 10;
  long s2 = 20;
  int diff = s2 - s1; // warning: 64 to 32
  
  return 0;
}

clang (trunk) only warns for the integer case. Is there a way to get
warnings for the double->float conversion too?

Thanks,

The generic "warn about any implicit conversions that might lose precision"
warning is -Wconversion. Clang's implementation of that is similar to
gcc-4.3's, i.e. substantially better than gcc-4.2's.

-Wshorten-64-to-32 was never supposed to be more than a portability
warning, which is why I didn't warn about double->float in clang's
implementation. Note that -Wshorten-64-to-32 is implied by -Wconversion.

John.

Ahh, that's good news. I'm used to thinking of -Wconversion as useless,
since it is in Apple's gcc 4.2.

Am I looking in the wrong place for warning docs? I don't see -
Wconversion here:

<http://clang.llvm.org/docs/UsersManual.html&gt;

Cheers,

The generic "warn about any implicit conversions that might lose precision"
warning is -Wconversion. Clang's implementation of that is similar to
gcc-4.3's, i.e. substantially better than gcc-4.2's.

Ahh, that's good news. I'm used to thinking of -Wconversion as useless,
since it is in Apple's gcc 4.2.

Well, let us know if you have any problems with false positives.

Am I looking in the wrong place for warning docs? I don't see -
Wconversion here:

Right now, we don't have any good documentation for the set of
warning categories we support.

John.