Article View: gnu.gcc.bug
Article #1002GCC 2.2.2 wrongly warns that '\x000000000' is out of range
From: Paul Eggert
Date: Thu, 27 Aug 1992 01:25
Date: Thu, 27 Aug 1992 01:25
81 lines
2275 bytes
2275 bytes
Given the program
char x = '\x000000000';
GCC 2.2.2 (SunOS 4.1.2, Sparc) wrongly complains:
t.c:1: warning: hex escape out of range
Here is a patch.
Thu Aug 27 01:15:00 1992 Paul Eggert (eggert@twinsun.com)
* c-lex.c (readescape): Leading zeros do not contribute to a hex
escape's size when checking for overflow.
===================================================================
RCS file: c-lex.c,v
retrieving revision 2.2.2.2
diff -c -r2.2.2.2 c-lex.c
*** c-lex.c 1992/07/24 18:54:59 2.2.2.2
--- c-lex.c 1992/08/27 01:15:00
***************
*** 741,747 ****
{
register int c = getc (finput);
register int code;
! register unsigned count;
unsigned firstdig;
switch (c)
--- 741,747 ----
{
register int c = getc (finput);
register int code;
! register int count;
unsigned firstdig;
switch (c)
***************
*** 754,760 ****
return c;
code = 0;
! count = 0;
while (1)
{
c = getc (finput);
--- 754,760 ----
return c;
code = 0;
! count = -1;
while (1)
{
c = getc (finput);
***************
*** 773,782 ****
if (c >= '0' && c <= '9')
code += c - '0';
if (count == 0)
! firstdig = code;
count++;
}
! if (count == 0)
error ("\\x used with no following hex digits");
else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
|| (count > 1
--- 773,785 ----
if (c >= '0' && c <= '9')
code += c - '0';
if (count == 0)
! {
! firstdig = code;
! count = code ? 0 : -1;
! }
count++;
}
! if (count < 0)
error ("\\x used with no following hex digits");
else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
|| (count > 1
Technical Details
Message-ID:
<9208270125.AA29484@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Subject: GCC 2.2.2 wrongly warns that '\x000000000' is out of range Message-ID: <9208270125.AA29484@farside.twinsun.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 27 Aug 1992 01:25:11 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 82