[Bug c/30116] New: faulty -Wformat warning with pointers to arrays

herring at lanl dot gov gcc-bugzilla@gcc.gnu.org
Thu Dec 7 21:16:00 GMT 2006


Compiling this with -pedantic and -Wformat gives the warning message that
follows it.

#include<stdio.h>

int main() {
  int a[1],(*b)[1]=&a;
  printf("%p",b);
  return 0;
}

test.c: In function ‘main’:
test.c:5: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type
‘int (*)[0u]’

I believe the warning is correct, but note the type given for b: the size is
wrong (it's always one less than the correct size) and there's a random "u"
added, perhaps due to a bug in a format string in gcc.  (How ironic if so!)


-- 
           Summary: faulty -Wformat warning with pointers to arrays
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: herring at lanl dot gov
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list