This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/20642] New: use printf to print a field of a struct followed by a second value. The second value prints as zero.
- From: "setterg at att dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Mar 2005 20:59:47 -0000
- Subject: [Bug c/20642] New: use printf to print a field of a struct followed by a second value. The second value prints as zero.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
// This illustrates a problem with the gnu c compiler
// GCC (GCC) 3.3.3 (cygwin special)
// The problem is when printing a field of a struct with printf,
// the second value is zero.
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(int argc, char* argv[])
{
struct stat st;
st.st_size = 3;
long filesize = st.st_size;
//this give st.st_size=3 cast=0
printf("st.st_size=%i cast=%i\n",st.st_size,(long)st.st_size);
//this outputs filesize=3 cast=3
printf("filesize=%i cast=%i\n",filesize ,(long) filesize);
return 0;
}
--
Summary: use printf to print a field of a struct followed by a
second value. The second value prints as zero.
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: setterg at att dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20642