public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21962] New: [bogus warning] format '%012llx' expects type X, but argument has type X
@ 2005-06-08 14:55 pluto at agmk dot net
  2005-06-08 15:04 ` [Bug c/21962] 4.0/4.1 Regression] ] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pluto at agmk dot net @ 2005-06-08 14:55 UTC (permalink / raw)
  To: gcc-bugs

extern void print(const char *my_format, ...)
__attribute__((format(printf, 1, 2)));

typedef struct {
    unsigned long long family:8, id:48, crc:8;
} bar;

void foo(bar *x)
{
    print("%012llx\n", x->id);
}


$ gcc  testcase.c -c -Wall
testcase.c: In function 'foo':
testcase.c:9: warning: format '%012llx' expects type 'long long unsigned int',
                       but argument 2 has type 'long long unsigned int'

$ gcc -v
Reading specs from /usr/lib/gcc/i686-pld-linux/4.0.1/specs
Target: i686-pld-linux
Configured with: ../configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-languages=c,c++,f95,objc,ada,java --enable-c99 --enable-long-long
--disable-multilib --enable-nls --with-gnu-as --with-gnu-ld
--with-demangler-in-ld --with-system-zlib --with-slibdir=/lib --without-x
--enable-cmath --enable-libgcj --enable-libgcj-multifile
--enable-libgcj-database --enable-gtk-cairo i686-pld-linux
Thread model: posix
gcc version 4.0.1 20050521 (prerelease) (PLD Linux)

-- 
           Summary: [bogus warning] format '%012llx' expects type X, but
                    argument has type X
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pld-linux
  GCC host triplet: i686-pld-linux
GCC target triplet: i686-pld-linux


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


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

* [Bug c/21962] 4.0/4.1 Regression] ] format '%012llx' expects type X, but argument has type X
  2005-06-08 14:55 [Bug c/21962] New: [bogus warning] format '%012llx' expects type X, but argument has type X pluto at agmk dot net
@ 2005-06-08 15:04 ` pinskia at gcc dot gnu dot org
  2005-06-08 16:32 ` joseph at codesourcery dot com
  2005-07-12  4:18 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-08 15:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-08 15:04 -------
: Search converges between 2004-07-08-trunk (#482) and 2004-07-09-trunk (#483).

Confirmed, I think this is related to the bitfield changes.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-08 15:04:56
               date|                            |
            Summary|[bogus warning] format      |4.0/4.1 Regression] ] format
                   |'%012llx' expects type X,   |'%012llx' expects type X,
                   |but argument has type X     |but argument has type X


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


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

* [Bug c/21962] 4.0/4.1 Regression] ] format '%012llx' expects type X, but argument has type X
  2005-06-08 14:55 [Bug c/21962] New: [bogus warning] format '%012llx' expects type X, but argument has type X pluto at agmk dot net
  2005-06-08 15:04 ` [Bug c/21962] 4.0/4.1 Regression] ] " pinskia at gcc dot gnu dot org
@ 2005-06-08 16:32 ` joseph at codesourcery dot com
  2005-07-12  4:18 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2005-06-08 16:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2005-06-08 16:32 -------
Subject: Re:  New: [bogus warning] format '%012llx' expects type
 X, but argument has type X

On Wed, 8 Jun 2005, pluto at agmk dot net wrote:

> extern void print(const char *my_format, ...)
> __attribute__((format(printf, 1, 2)));
> 
> typedef struct {
>     unsigned long long family:8, id:48, crc:8;
> } bar;
> 
> void foo(bar *x)
> {
>     print("%012llx\n", x->id);
> }
> 
> 
> $ gcc  testcase.c -c -Wall
> testcase.c: In function 'foo':
> testcase.c:9: warning: format '%012llx' expects type 'long long unsigned int',
>                        but argument 2 has type 'long long unsigned int'

The problem here is the text of the diagnostic, not the fact of the 
diagnostic - the argument type is really "unsigned long long:48" which is 
not promoted to plain unsigned long long, so there is indeed undefined 
behavior on execution.  I.e., pp_c_type_specifier where it does

      if (TYPE_NAME (t))
        t = TYPE_NAME (t);
      else
        t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
      pp_c_type_specifier (pp, t);

should check for the case of integer types with precision smaller than 
that of the mode and display them specially.



-- 


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


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

* [Bug c/21962] 4.0/4.1 Regression] ] format '%012llx' expects type X, but argument has type X
  2005-06-08 14:55 [Bug c/21962] New: [bogus warning] format '%012llx' expects type X, but argument has type X pluto at agmk dot net
  2005-06-08 15:04 ` [Bug c/21962] 4.0/4.1 Regression] ] " pinskia at gcc dot gnu dot org
  2005-06-08 16:32 ` joseph at codesourcery dot com
@ 2005-07-12  4:18 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-12  4:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-12 04:17 -------


*** This bug has been marked as a duplicate of 22421 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2005-07-12  4:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-08 14:55 [Bug c/21962] New: [bogus warning] format '%012llx' expects type X, but argument has type X pluto at agmk dot net
2005-06-08 15:04 ` [Bug c/21962] 4.0/4.1 Regression] ] " pinskia at gcc dot gnu dot org
2005-06-08 16:32 ` joseph at codesourcery dot com
2005-07-12  4:18 ` 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).