[Bug libfortran/45323] warnings compiling libgfortran/io/write.c: array subscript has type 'char'
fxcoudert at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Aug 23 08:37:00 GMT 2010
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2010-08-23 08:37 -------
(In reply to comment #1)
> That's the lines:
> 1472 char cup;
> 1467 size_t dim_i;
> 1504 cup = toupper (base_name[dim_i]);
> 1511 cup = toupper (obj->var_name[dim_i]);
> and
> 1743 char c;
> 1741 index_type i;
> 1760 c = toupper (dtp->namelist_name[i]);
>
> (with: typedef ssize_t index_type;)
>
> According to POSIX, toupper is defined as:
> int toupper(int c);
>
> I am not sure I understand the message itself:
> "array subscript has type 'char'"
> because in those lines I do not see how the array subscript can be 'char'. It
> might be due to the way Tru64 Unix implements "toupper".
Typically happens because when toupper is a macro that is equivalent to
something like:
#define toupper(x) (upper_table[x])
POSIX seems to says "shall be declared as functions and may also be defined as
macros".
> Does it help to cast the argument to (int)? I mean:
> - cup = toupper (base_name[dim_i]);
> + cup = toupper ((int) base_name[dim_i]);
> for all three toupper?
It should. Another solution is to force the function call (but that may mean
slower code):
cup = (toupper) (base_name[dim_i]);
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-08-23 08:37:12
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45323
More information about the Gcc-bugs
mailing list