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

Re: GCC 4.1 now the default GCC version for etch

On 16-Jun-06, 08:18 (CDT), Henning Makholm <henning@makholm.net> wrote: 
> Another related bug type that I found lurking in my packages when I
> investigated the warnings in this list, is trying to format a size_t
> value with a %u or %d format string, which will break if size_t is 64
> bits (unless the actual number is small and it is the last argument
> and the endianness of the architecture happens to match its stack
> growth direction). This too produces a warning on all relevant gcc
> versions, but only when compiling to a 64-bit target.

Actually, it will provide a warning on 32-bit platforms too, if one chooses the appropriate options (-Wall, or specifically -Wformat):

$ cat tprint.c
#include <stdio.h>

int main(void) {

        int i;
        size_t st;

        printf("%d %lu\n", i, st);
        return 0;

$ gcc -Wall tprint.c 
tprint.c: In function 'main':
tprint.c:8: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t'


Steve Greenland
    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world.       -- seen on the net

Reply to: