[LLVMdev] UnitTests/2003-05-31-CastToBool.c

Reid Spencer reid at x10sys.com
Wed Jul 7 07:19:01 PDT 2004


This program is in error. Either the format specifier needs to be %lld
or the argument value X needs to be casted to type long.  This will
compile fine but it probably won't work at runtime because printf is
expecting a long, not a long long. I think your backend producing "wrong
results" is actually correct :)

Most modern C/C++ compilers will detect this for you at compile time.
What compiler are you using?  


On Wed, 2004-07-07 at 04:51, Vladimir Prus wrote:
> I think test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c
> has a problem. Consider:
>      void testLong(long long X) {
>         printf("%ld ", X);
>         testBool(X != 0);
>      }
> This passes 'long long' value to 'ld' format specifier -- but for that 
> specifier the parameter should be 'long'. So, the behaviour of the above is 
> undefined and in fact it produces wrong results with my backend.
> Could extra 'l' be added in the format string?
> - Volodya
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20040707/b9d4e0a5/attachment.sig>

More information about the llvm-dev mailing list