Thread View: gnu.gcc.bug
2 messages
2 total messages
Started by Kenneth Herron
Wed, 07 Oct 1992 16:16
2.2.2 constant expression range checking
Author: Kenneth Herron
Date: Wed, 07 Oct 1992 16:16
Date: Wed, 07 Oct 1992 16:16
41 lines
2157 bytes
2157 bytes
Our gcc has had several of Paul Eggert's patches applied, and I think
one of them is at fault here, so if they're not to be considered
official then take this with a grain of salt.
This file, compiled with "gcc -c testit.c":
----------------
/* #include <sys/types.h> */
#ifndef u_char
#define u_char unsigned char
#endif
static u_char badmap[] = {
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
};
static char goodmap[] = {
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
};
----------------
produces:
----------------
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
gcc-test.c:8: warning: constant expression out of range for unsigned type
----------------
Uncommenting the #include line and commenting out the #define makes
no difference.
gcc -v returns:
Reading specs from /xbin/gnu/lib/gcc-lib/symmetry-dynix/2.2.2/specs
gcc version 2.2.2
--
Kenneth Herron kherron@ms.uky.edu
University of Kentucky +1 606 257 2975
Department of Mathematics I just thought of a neat disproof of
Fermat's last theorem, but .signatures can only be four lines.
Re: 2.2.2 constant expression range checking
Author: Paul Eggert
Date: Wed, 07 Oct 1992 18:40
Date: Wed, 07 Oct 1992 18:40
9 lines
861 bytes
861 bytes
>static u_char badmap[] = {
> '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
>};
>gcc-test.c:8: warning: constant expression out of range for unsigned type
The warning is correct, since '\200' equals -128, and -128 is out of
range for the type unsigned char. You can fix the problem by writing
0200 instead of '\200'.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads