This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
erroneous result computing an expression
- To: bug-gcc at gnu dot org
- Subject: erroneous result computing an expression
- From: Ludovic WALLE <walle at inist dot fr>
- Date: Fri, 24 Mar 2000 12:35:44 +0100
- Organization: INIST / CNRS
- Reply-To: walle at inist dot fr
I get an erroneous result computing an expression.
I tryed the following versions of gcc:
gcc version 2.8.1 on a HP 9000/879 with HP-UX 10.20 A
gcc version 2.95.2 19991024 (release) on a HP 9000/899 with HP-UX 11.00
A
I didn't used any options.
8<------------------------------------------------------
#include <stdio.h>
int main ()
{
char const buf[] = "Â ";
char const *pt;
char const **str;
char const *pt1;
char const *pt2;
/* a way of computing which works */
pt = buf;
str = &pt;
pt1 = (*str)++;
pt2 = (*str)++;
if ((((((int) *pt1) & 0x1FU) << 6) | (((int) *pt2) & 0x3FU)) !=
0xA0) {
printf ("ERROR\n");
} else {
printf ("OK\n");
}
/* this way of computing works with some compilers but doesn't work
with gcc ! */
pt = buf;
str = &pt;
if ((((((int) *((*str)++)) & 0x1FU) << 6) | (((int) *((*str)++)) &
0x3FU)) != 0xA0) {
printf ("ERROR\n");
} else {
printf ("OK\n");
}
return (0);
}
8<------------------------------------------------------
--
Ludovic WALLE
E-Mail : walle@inist.fr
Tel : 03.83.50.46.00 poste 8681