Package: sparse
Version: 0.4-2
Severity: normal

On amd64, both "unsigned long" and "unsigned long long" are 64 bits. On this
architecture, I would therefore expect sparse to generate the same warnings
relating to both types. This is not the case however, as illustrated by the
test code below. Is this a bug in sparse, or am I misunderstanding sparse's
behaviour in this case?


/* Build with `cgcc -Wall test.c' */

#include <stdio.h>

int main(int argc, char **argv) {
        long int li;
        long long int lli;

        printf("sizeof(unsigned long): %li\n", sizeof(unsigned long));
        /* Outputs `sizeof(unsigned long): 8' */

        printf("sizeof(unsigned long long): %li\n", sizeof(unsigned long 
long)); /* Outputs `sizeof(unsigned long long): 8' */

        printf("sizeof(unsigned long) == sizeof(unsigned long long): %i\n",
                sizeof(unsigned long) == sizeof(unsigned long long));
        /* Outputs `sizeof(unsigned long) == sizeof(unsigned long long): 1' */

        li = (11644473600UL);
        /* sparse outputs
                warning: constant 11644473600UL is so big it is unsigned long 
long
                warning: cast truncates bits from constant value (2b6109100 
becomes b6109100)
        */

        printf("%li\n", li); /* Outputs `11644473600', so nothing was truncated 
*/

        li = (11644473600ULL);
        /* sparse results:
                warning: cast truncates bits from constant value (2b6109100 
becomes b6109100)
        */
        printf("%li\n", li); /* Outputs `11644473600', so nothing was truncated 
*/

        lli = (11644473600ULL);
        printf("%lli\n", lli); /* Outputs `11644473600' */

        return 0;
}


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing-proposed-updates'), (500, 
'stable'), (400, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.23.1 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages sparse depends on:
ii  libc6                         2.6.1-6    GNU C Library: Shared libraries

sparse recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to