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]

Re: printf or stdargs bug (one-liner).


Not bug for unsigned long long use %llu (if you add -Wall, you will get a warning about %lu excepts unsigned long).
In fact right now big-endian machines you will get a different result:


test1:  0 8
test1:  4 0

Thanks,
Andrew Pinski

On Wednesday, Jun 4, 2003, at 19:49 US/Eastern, Yuri Dotsenko wrote:

Hi,

It was discovered that gcc (3.2.2 or 3.3) both miscompile the following code:


#include "stdio.h"


int main() {
 unsigned long long lu;
 int d;
 lu = 8;
 d = 4;

 printf("test1:  %lu %d\n", lu, d);  // prints: 8 0, instead of 8 4
 printf("test1:  %d %lu\n", d, lu);  // prints: 4 8 - Ok

 return 0;
}


Thanks, Yuri






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