This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/26921] New: long long bit fields are passed to variadic functions as longs


When compiled under Linux, at least, gcc 3.2.3 appears to pass a long long bit
field to a variadic function as a long.  In particular, if you say "printf
("%lld", s.a)", where s.a is a long long bit field, s.a appears to only pass a
long.

The resulting assembly reads (for a 3 bit long long field):
        movb    foo, %al
        sall    $5, %eax
        movb    %al, %cl
        sarb    $5, %cl
        movsbl  %cl,%eax
        cltd
        pushl   %eax
        pushl   $.LC0
        call    printf

I do not believe this is correct behavior for gcc.

With -Wall, the above example generates a warning about the operation:
a.c: In function `main':
a.c:10: warning: long long int format, different type arg (arg 2)

I see similar behavior on gcc 4.0.0 on a Macintosh, but that's based on the
output produced by the executible, since I cannot read it's assembly.

Compiled using: gcc -Wall -v --save-temps a.c


-- 
           Summary: long long bit fields are passed to variadic functions as
                    longs
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bugzilla at hburch dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]