"Lemley James - jlemle" <[EMAIL PROTECTED]> writes:

> --- begin IBM note ---
> Hi James, 
>
> This is not a defect.  I wrote a new testcase that exhibits the same
> behaviour as the one that was submitted.

IBM's test case is fine, but it's not related to the bug.  The
bug, as I understand it, is exhibited when you use bool.  IBM's
test case does not involve bool.

Here's a test case that should illustrate the bug:

        #include <stdio.h>
        #include <stdbool.h>

        int main()

        {
              bool b = true;


              char c[] = "0123456789";
              char *d = c + 5;

              printf("b is true, which is %x (should be 1)\n", b );
              printf("d is %p\n", d);
              printf("-2 + b is %d (should be -1)\n", -2 + b);
              printf("&d[-1] is %p\n", &d[-1]);
              printf("&c[4] is %p\n", &c[4]);
              printf("&d[-2 + b] is %p\n", &d[-2 + b]);
              if (&d[-2 + b] == &c[4])
                printf("&d[-2 + b] == &c[4] (OK)\n");
              else
                printf("&d[-2 + b] != &c[4] (wrong)\n");

              return 0;
        }

On my 64-bit machine, it outputs this:

        b is true, which is 1 (should be 1)
        d is ffffffff7ffff701
        -2 + b is -1 (should be -1)
        &d[-1] is ffffffff7ffff700
        &c[4] is ffffffff7ffff700
        &d[-2 + b] is ffffffff7ffff700
        &d[-2 + b] == &c[4] (OK)

But my understanding is that you get different (and incorrect) output
with IBM's compiler.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to