tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Wrong __int64 computation


From: Christian Jullien
Subject: [Tinycc-devel] Wrong __int64 computation
Date: Fri, 18 Dec 2009 12:18:02 +0100

Here is a simple test case that shows the bug:

#include <stdio.h>

int
main()
{
        int     i = 16;
        __int64 j = 16;
        unsigned __int64        n;

        // Use %p to show all bits

        n = 0x7fffffffffff;
        printf("Init:  n=%p, sizeof(n) = %d\n", n, sizeof(n)); // == 8 Ok!

        n = 0x7fffffffffff;
        n = n / i; // i is an int
        printf("Wrong: n=%p\n", n);

        n = 0x7fffffffffff;
        n = n / j; // j is an __int64
        printf("Wrong: n=%p\n", n);

        n = 0x7fffffffffff;
        n = n / 16;
        printf("Good:  n=%p\n", n);

}








reply via email to

[Prev in Thread] Current Thread [Next in Thread]