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]

erroneous result computing an expression


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



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