Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul Eggert
Wed, 06 Jan 1993 02:25
GCC 2.3.3 cpp violates array bounds when given chars with top bit on
Author: Paul Eggert
Date: Wed, 06 Jan 1993 02:25
Date: Wed, 06 Jan 1993 02:25
89 lines
2877 bytes
2877 bytes
When given the program
#if \377
#endif
where the `\377' stands for a single character with all bits on,
the preprocessor for GCC 2.3.3 (sparc, SunOS 4.1.2) addresses
outside the bounds of an array due to signed character extension.
Here is a patch.
Wed Jan 6 02:16:48 1993 Paul Eggert (eggert@twinsun.com)
* cexp.y (yylex): Don't use signed chars to index into arrays;
they might be negative.
===================================================================
RCS file: cexp.y,v
retrieving revision 2.3
diff -c -r2.3 cexp.y
*** cexp.y 1992/10/21 06:53:52 2.3
--- cexp.y 1993/01/06 02:10:19
***************
*** 467,473 ****
retry:
tokstart = lexptr;
! c = *tokstart;
/* See if it is a special token of length 2. */
if (! keyword_parsing)
for (toktab = tokentab2; toktab->operator != NULL; toktab++)
--- 467,473 ----
retry:
tokstart = lexptr;
! c = (unsigned char) *tokstart;
/* See if it is a special token of length 2. */
if (! keyword_parsing)
for (toktab = tokentab2; toktab->operator != NULL; toktab++)
***************
*** 688,694 ****
if (c >= '0' && c <= '9' && !keyword_parsing) {
/* It's a number */
for (namelen = 0;
! c = tokstart[namelen], is_idchar[c] || c == '.';
namelen++)
;
return parse_number (namelen);
--- 688,694 ----
if (c >= '0' && c <= '9' && !keyword_parsing) {
/* It's a number */
for (namelen = 0;
! c = (unsigned char) tokstart[namelen], is_idchar[c] || c == '.';
namelen++)
;
return parse_number (namelen);
***************
*** 698,704 ****
if (keyword_parsing) {
for (namelen = 0;; namelen++) {
! if (is_hor_space[tokstart[namelen]])
break;
if (tokstart[namelen] == '(' || tokstart[namelen] == ')')
break;
--- 698,704 ----
if (keyword_parsing) {
for (namelen = 0;; namelen++) {
! if (is_hor_space[(unsigned char) tokstart[namelen]])
break;
if (tokstart[namelen] == '(' || tokstart[namelen] == ')')
break;
***************
*** 711,717 ****
return ERROR;
}
! for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
;
}
--- 711,717 ----
return ERROR;
}
! for (namelen = 0; is_idchar[(unsigned char) tokstart[namelen]]; namelen++)
;
}
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