printf bug ??!
Thomas Kuehne
thomas-dloop at kuehne.cn
Thu Mar 16 11:45:34 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
lanael schrieb am 2006-03-16:
> void main() {
> ulong u =0b100000000000000000000000000000000000000000000000; // 1 and
> 47 zeros
> ulong u1=0b1000000000000000000000000000000000000000000000000; // 1 and
> 48 zeros
> printf("u = \t %llx \t %llb\n",u,u);
> printf("u1 = \t %llx \t %llb\n",u1,u1);
> }
>
> output :
> u = 800000000000
> 100000000000000000000000000000000000000000000000
> u1 = 1000000000000
> 000000000000000000000000000000000000000000000000
>
> it looks like a buffer overflow...
The %llb notation isn't part of the standard printf implementation.
(see C99, ISO 9899 7.19.6.1.8)
I'm not saying that this is a bug or not, but the code isn't portable:
> #include <stdio.h>
>
> int main(){
> unsigned long long i = 9;
> printf("%llb\n", i);
> return 0;
> }
prints "%b" under Linux
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEGcuj3w+/yD4P9tIRAqu7AKCpEp/rD8aVQO8quVn6KH5rp7zxvACdGelJ
SWSf/QenPQsqubs6ftznCOg=
=70Te
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list