This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Unsigned char logical operations
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Unsigned char logical operations
- From: Duane Ellis <duane_ellis at franklin dot com>
- Date: Tue, 20 Jun 2000 19:48:04 -0400
- Reply-to: duane_ellis at franklin dot com
GCC 2.95.2, configured as follows:
Linux, Red Hat 6.1 (Intel i686)
tar xfz gcc-2.95.2.tar.gz
cd gcc-2.95.2
./configure [see output of config.status below]
make
make install
cat config.status, shows this:
./configure --with-gcc-version-trigger=/nbu/ereader/duane/gcc-2.95.2/gcc/version.c --host=i686-pc-linux-gnu --prefix=/nbu/ereader/duane/install --norecursion
Any questions, please contact me.
Thanks,
--Duane.
This small piece of code reports the wrong values.
--------------------------------------------------
/* Assumes ASCII char set, */
typedef unsigned char U8;
#define MY_BIT 0x08
U8 data[ 16 ];
char string[10];
static void
do_char( char *str, int i, int flag, int ch )
{
if( flag ){
str[i] = ch + 0x20; /* capitalize it */
} else {
str[i] = ch;
}
}
int
main( int argc, char **argv )
{
int indx;
int x;
/* BUG BUG BUG BUG */
x = 0;
indx = 3;
data[ indx ] = 0x0ff;
do_char( string, x, data[ indx ] & MY_BIT, 'd' );
string[1] = 0;
printf("Result is: %s\n", string );
/* Should print 'D' */
/* THIS VERSION IS OK */
x = 0;
indx = 3;
data[ indx ] = 0x000;
do_char( string, x, data[ indx ] & MY_BIT, 'd' );
string[1] = 0;
printf("Result is: %s\n", string );
/* should print 'd' */
}