------- Comment #7 from fxcoudert at gcc dot gnu dot org  2006-05-28 19:56 
-------
(In reply to comment #6)
> Have you read 4.3.2.1.1?  This defines the requirements on the
> collating of the default character type.  It also defines the
> requirements on LGT, LGE, LLE, and LLT, which is why we use the
> ascii_table in simplify.c.

OK, I see. I think we don't have users around here using non ASCII-based
charsets, and I also think other parts of the front-end and library would fall
apart on such systems, but anyway, that's not the point.

Anyway, I know it's standard conforming, but having both LLE("é","è") and
LGE("é","è") returning true is... always surprising.

> Thomas' idea of using unsigned char does not conflict with
> 4.3.2.1.1.

Yes, but C strings are char by default and not unsigned char, so I guess we'd
best avoid changing that. But, a less invasive fix could be:

Index: simplify.c
===================================================================
--- simplify.c  (revision 113849)
+++ simplify.c  (working copy)
@@ -67,7 +67,7 @@
 /* Static table for converting non-ascii character sets to ascii.
    The xascii_table[] is the inverse table.  */

-static int ascii_table[256] = {
+static unsigned char ascii_table[256] = {
   '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
   '\b', '\t', '\n', '\v', '\0', '\r', '\0', '\0',
   '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
@@ -86,7 +86,7 @@
   'x', 'y', 'z', '{', '|', '}', '~', '\?'
 };

-static int xascii_table[256];
+static unsigned int xascii_table[256];


 /* Range checks an expression node.  If all goes well, returns the
@@ -1196,7 +1196,7 @@
       return &gfc_bad_expr;
     }

-  index = xascii_table[(int) e->value.character.string[0] & 0xFF];
+  index = xascii_table[(unsigned char) e->value.character.string[0] & 0xFF];

   result = gfc_int_expr (index);
   result->where = e->where;
@@ -4016,9 +4016,9 @@
 /* Given a collating table, create the inverse table.  */

 static void
-invert_table (const int *table, int *xtable)
+invert_table (const unsigned char *table, unsigned int *xtable)
 {
-  int i;
+  unsigned int i;

   for (i = 0; i < 256; i++)
     xtable[i] = 0;
Index: arith.c
===================================================================
--- arith.c     (revision 113849)
+++ arith.c     (working copy)
@@ -1122,9 +1122,10 @@
    collating sequence.  */

 int
-gfc_compare_string (gfc_expr * a, gfc_expr * b, const int *xcoll_table)
+gfc_compare_string (gfc_expr * a, gfc_expr * b, const unsigned int
*xcoll_table)
 {
-  int len, alen, blen, i, ac, bc;
+  int len, alen, blen, i;
+  unsigned char ac, bc;

   alen = a->value.character.length;
   blen = b->value.character.length;
Index: arith.h
===================================================================
--- arith.h     (revision 113849)
+++ arith.h     (working copy)
@@ -41,7 +41,7 @@
 arith gfc_range_check (gfc_expr *);

 int gfc_compare_expr (gfc_expr *, gfc_expr *);
-int gfc_compare_string (gfc_expr *, gfc_expr *, const int *);
+int gfc_compare_string (gfc_expr *, gfc_expr *, const unsigned int *);

 /* Constant folding for gfc_expr trees.  */
 gfc_expr *gfc_uplus (gfc_expr * op);


Comments on this one?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27715

Reply via email to