Code below generates an incorrect warning:

$ gcc -Wall -c temp.c
temp.c:4: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has
type ‘unsigned int’

$ cat temp.c
int format (const char * f, ...) __attribute__ ((format (printf, 1, 2)));
void bar (unsigned int x)
{
    format ("%x", __builtin_bswap32 (x));
}

Unless I'm going mad, ‘unsigned int’ and ‘unsigned int’ are identical.

Giving an explicit prototype of __builtin_bswap32 works-around.

$ gcc --version ; rpm -q gcc

gcc (GCC) 4.3.2 20080917 (Red Hat 4.3.2-4)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc-4.3.2-4.x86_64


-- 
           Summary: Bogus printf format warning with __builtin_bswap32.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: suckfish at ihug dot co dot nz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37743

Reply via email to