public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/29358]  New: Warning issued two times with snprintf
@ 2006-10-05 17:04 pf dot hugues at gmail dot com
  2006-10-05 17:07 ` [Bug c/29358] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: pf dot hugues at gmail dot com @ 2006-10-05 17:04 UTC (permalink / raw)
  To: gcc-bugs

The following snipped of code compiled with -Wall emits two times the same
warning : 

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

int     main(void)
{
  uint32_t foo = 42;
  char bar[] = "bla";
  char *buffer = malloc(10);

  snprintf(buffer, 10, "%lu %s\n", foo, bar);

  free(buffer);
  return 0;
}
gcc -Wall bug.c
bug.c: In function 'main':
bug.c:11: warning: format '%lu' expects type 'long unsigned int', but argument
4 has type 'uint32_t'
bug.c:11: warning: format '%lu' expects type 'long unsigned int', but argument
4 has type 'uint32_t'

I tried on several flavors (4.0.3, 4.0.4, 4.1.2), the result is the same. If
sprintf is used instead of snprintf, the warning is emitted only one time.

Tests were made on x68 platforms with gcc for x86 and mipsel


-- 
           Summary: Warning issued two times with snprintf
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pf dot hugues at gmail dot com


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-03  8:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-29358-4@http.gcc.gnu.org/bugzilla/>
2012-01-14  0:23 ` [Bug c/29358] Warning issued two times with snprintf pinskia at gcc dot gnu.org
2015-05-21 12:13 ` mpolacek at gcc dot gnu.org
2015-06-03  8:28 ` mpolacek at gcc dot gnu.org
2006-10-05 17:04 [Bug c/29358] New: " pf dot hugues at gmail dot com
2006-10-05 17:07 ` [Bug c/29358] " pinskia at gcc dot gnu dot org
2006-10-05 17:10 ` joseph at codesourcery dot com
2006-10-05 17:11 ` pf dot hugues at gmail dot com
2006-10-05 17:16 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).