Bug 455090

Summary: incorrect output for printf("%lld")
Product: [Fedora] Fedora Reporter: Gene Czarcinski <gczarcinski>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-07-11 21:55:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
error demo c program none

Description Gene Czarcinski 2008-07-11 21:29:22 UTC
Description of problem:
Attached is an extremely simple program which prints some numbers with
formatting of "%d", "%ld", and "%lld"

On x86_64, I am getting the expected results but on i386 I am getting garbage
when I run it on i386 Fedora 9.

see below

Version-Release number of selected component (if applicable):
Fedora 9 plus (more or less) recent updates

How reproducible:
yes
-------------------------------------------
x86_64:

short   = 2 bytes
int     = 4 bytes
long    = 8 bytes
long long 8 bytes
pointer = 8 bytes

 testing   d: 12345, 5890123, 6901234, 448989898
 testing  ld: 12345, 5890123, 6901234, 448989898
 testing lld: 12345, 5890123, 6901234, 448989898
----------------------------------------------------------
On i386:
short   = 2 bytes
int     = 4 bytes
long    = 4 bytes
long long 8 bytes
pointer = 4 bytes

 testing   d: 12345, 5890123, 6901234, 448989898
 testing  ld: 12345, 5890123, 6901234, 448989898
 testing lld: 25297885654429753, 1928396928151277042, 0, 134514269

Comment 1 Gene Czarcinski 2008-07-11 21:29:22 UTC
Created attachment 311622 [details]
error demo c program

Comment 2 Jakub Jelinek 2008-07-11 21:55:19 UTC
And what do you expect?  The program is clearly invalid.  You are passing vars
to ... which don't match the expected types from the format string.
POSIX says:
"If any argument is not the correct type for the corresponding conversion
specification, the behavior is undefined." and that's exactly what happened.