c/3112: printf error for structs with "long long" members
ydi@eecs.uic.edu
ydi@eecs.uic.edu
Sun Jun 10 17:26:00 GMT 2001
>Number: 3112
>Category: c
>Synopsis: printf error for structs with "long long" members
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 10 17:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Yu Di
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Solaris 2.7, Generic_106541-12 sun4u sparc SUNW,Ultra-60
>Description:
If we try to print several member variables in a struct, with one of them being "long long" type, the other member variable displays will be also wrong.
If the following program is compiled and executed, it outputs "0,20" instead of "20,10"
#include <stdio.h>
main()
{
struct aaa {
unsigned long long x;
unsigned short y;
} a;
a.x = 20;
a.y = 10;
printf("%lu, %d\n", a.x, a.y);
/*We know that %lu can't work for a.x, but it shouldn't affect a.y. If we change the sentence to printf("%lf, ...), it will work correctly for both values */
}
>How-To-Repeat:
See our program in the description
>Fix:
N/A
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list