Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Nov 2000 21:03:32 GMT
From:      Salvo Bartolotta <bartequi@inwind.it>
To:        freebsd-questions@FreeBSD.ORG
Subject:   OT: curious (??) integer types behavio(u)r... 
Message-ID:  <20001112.21033200@bartequi.ottodomain.org>

next in thread | raw e-mail | index | archive | help
[ not sure whether/where to send this dumb remark ]

Dear FreeBSD'ers,

The following simple (test) program seems to behave anomalously on my
FreeBSD 4.2-BETA (sources as of this morning) PIII system.

<blockquote>
/* A simple test program */

#include <stdio.h>

main()
     {
           char c1 =3D -128;
           char c2 =3D 127;
           unsigned char c =3D 255;

           short int si1 =3D -32768;
           short int si2 =3D 32767;
           unsigned short int si =3D 65535;

           int d1 =3D -2147483648;
           int d2 =3D 2147483647;
           unsigned int d =3D 4294967295;
           unsigned long int l =3D 4294967295;   /* redundant */

           printf("%d %d %d %d %d %d %d %d %d %ld\n", c1, c2, c, si1,
si2, si, d1, d2, d, l);
     }

</blockquote>

>=3D=3D=3D=3D> cc -o mytest mytest.c
mytest.c: In function `main':
mytest.c:15: warning: decimal constant is so large that it is unsigned
mytest.c:17: warning: decimal constant is so large that it is unsigned
mytest.c:18: warning: decimal constant is so large that it is unsigned


>=3D=3D=3D=3D> ./mytest
-128 127 255 -32768 32767 65535 -2147483648 2147483647 -1 -1
                                     (?)               ^^^^^^



To sum up:
1) cc complains about line 15, but the limit is correctly displayed by
the program (!);
2) cc complains about lines 17 and 18; the limits are INcorrectly
displayed.

I am probably missing something very trivial here.

TIA for any enlightenment,
Salvo





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001112.21033200>