This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/4938: bad warnings about signed and unsigned
- From: inouk at igt dot net
- To: gcc-gnats at gcc dot gnu dot org
- Date: 24 Nov 2001 03:52:37 -0000
- Subject: c/4938: bad warnings about signed and unsigned
- Reply-to: inouk at igt dot net
[Get raw message]
>Number: 4938
>Category: c
>Synopsis: bad warnings about signed and unsigned
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Nov 23 19:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: inouk@igt.net
>Release: unknown-1.0
>Organization:
>Environment:
Debian GNU/Linux GCC version 2.95 and 3.0
>Description:
The range of signed int is between -2147483648 and 2147483647
unsigned int between 0 and 4294967295
here a sample code:
1 int main(void) {
2
3 unsigned int test;
4 int test1;
5
6 test = 4294967295;
7 test = 2147483648;
8 test = 2147483647;
9
10 test1 = 2147483647;
11 test1 = -2147483648;
12 test1 = -2147483647;
13 }
I compile this and I have:
gcc t2.c
t2.c: In function `main':
t2.c:6: warning: decimal constant is so large that it is unsigned
t2.c:7: warning: decimal constant is so large that it is unsigned
t2.c:11: warning: decimal constant is so large that it is unsigned
I have a little difference with short, I never see warnings.
signed short: -32768 to 32767
unsigned short: 0 to 65535
sample code:
1 int main(void) {
2
3 unsigned short test;
4 short test1;
5
6 test = 65535;
7
8 test1 = 65535;
9 test1 = 32767;
10 }
nothing about warning. But, i "overflowed" test1 (in line 8).
>How-To-Repeat:
go to description
>Fix:
Better handling warnings :)
>Release-Note:
>Audit-Trail:
>Unformatted: