This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g77 ichar signed?

[Get raw message]
The proprietary red hat version of g77 to which you refer is maintained only
by red hat, and any correlation to public versions is coincidental.  As you
show, it may be out of date in this respect.  I prefer to run the gcc-3.1 on
my installation.  If you have a bug related to a gcc version of g77, it is
often sufficient to submit a short source code and the screen echo from
g77 -v.
----- Original Message -----
From: "MASUDA Kooiti" <masuda@frontier.esto.or.jp>
To: <gcc-bugs@gcc.gnu.org>
Cc: <masuda@frontier.esto.or.jp>
Sent: Friday, November 30, 2001 5:47 AM
Subject: g77 ichar signed?


> To g77 developpers:
>
> I am a Fortran programmer using 'g77' on several installations of Linux.
> It is very useful software, and it is generally very portable.
>
> However, I recently found an unexpected behaviour of the intrinsic
> function 'ichar' in some version of 'g77' (but not in others).
>
> The problem is that 'ichar' returns signed integer values (-128..127)
> if the argument is a character variable, while it returns unsigned
> values (0..255) if the argument is a literal character.
>
> The version is
> > g77 version 2.96 20000731 (Red Hat Linux 7.0)
> > (from FSF-g77 version 0.5.26 20000731 (Red Hat Linux 7.0))
> I have browsed your WWW pages and searched for 'ichar' and 'signed',
> and found nothing in particular.
> I am sure that this is not the latest version of 'gcc', but please
> forgive me that I am not able to build a later version of 'gcc' than
> the Linux distribution provides.
> Also it is difficult for me to follow strictly the guideline for
> reporting 'gcc' bugs, which seems to be intended primary for
> such bugs that crash the compiler.
>
> The problem does not appear, at least, in the following version.
> > g77 version egcs-2.91.66 19990314 (egcs-1.1.2 release)
> > (from FSF-g77 version 0.5.24-19981002)
> The returned values are always unsigned there.
>
> For more information about the version of 'g77' with trouble,
> the first and last parts of the output of 'g77 --verbose' is as follows
> g77 version 2.96 20000731 (Red Hat Linux 7.0)
> (from FSF-g77 version 0.5.26 20000731 (Red Hat Linux 7.0))
> ...
> __G77_LIBF77_VERSION__: 0.5.26 20000731 (prerelease)
> @(#)LIBF77 VERSION 19991115
> __G77_LIBI77_VERSION__: 0.5.26 20000731 (prerelease)
> @(#) LIBI77 VERSION pjw,dmg-mods 19991115
> __G77_LIBU77_VERSION__: 0.5.26 20000731 (prerelease)
> @(#) LIBU77 VERSION 19980709
>
> I tested it with the following Fortran program
> (between <pre> and </pre>).  In order to keep e-mail message in
> 7-bit code, I follow the convention of HTML.  The string '&auml;'
> is actually a one-byte character in Latin-1 (a-Umlaut in German).
> <pre>
>       CHARACTER h
> *
>       h = '&auml;'
>       WRITE(*,*) 'h = ',h
>       WRITE(*,*) 'ichar(h) = ', ichar(h)
>       WRITE(*,*) 'ichar(''&auml;'') = ', ichar('&auml;')
>       END
> </pre>
>
> The operation is just as follows, and there is no error messages.
> g77 ticharau.f
> ./a.out > ticharau.out
>
> The output is as follows (again '&auml;' is a character):
> <pre>
>  h = &auml;
>  ichar(h) =  -28
>  ichar('&auml;') =  228
> </pre>
>
> As I already know the problem, I can work around it by using such a
> code as:
>       INTEGER   iuchar(h)
>       CHARACTER h
>       INTEGER   ic
> *
>       ic = ichar(h)
>       IF(ic .LT. 0) ic = ic + 256
>       iuchar = ic
>       RETURN
>       END
> But it looks ugly.
>
> I am not sure whether the Fortran standard forces that the values
> returned from 'ichar' should be unsigned or not.
> However, it should be consistent anyway.
>
> By the way, 'f2c' (from netlib.bell-labs.com) as of 22 Aug. 2001
> returns unsigned values (228 in the both positions of the above example).
> In the 'CHANGES' file of 'f2c', there is the following entry.
> >Fri Sep 16 17:50:18 EDT 1994
> ...
> >  Arrange for ichar() to treat characters as unsigned.
> >  libf77: s_cmp.c: treat characters as unsigned in comparisons.
> >These changes for unsignedness only matter for strings that contain
> >non-ASCII characters.  Now ichar() should always be >= 0.
> --
> Kooiti MASUDA (D. Sc.)
> Frontier Reserch System for Global Change
> Showa, Kanazawa-ku, Yokohama 236-0001, Japan
> masuda@frontier.esto.or.jp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]