ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/09/05/17:19:27

From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200209041131.NAA16683@lws256.lu.erisoft.se>
Subject: Re: DJGPP Bug Activity
To: djgpp-workers AT delorie DOT com
Date: Wed, 4 Sep 2002 13:31:41 +0200 (MET DST)
In-Reply-To: <3D71BC30.FF92C656@phekda.freeserve.co.uk> from "Richard Dawe" at Sep 01, 2002 08:05:20 AM
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Richard said:
> > 08/03/2002 16:31:03: Create 000354:2.03 printf()'s %#08x handling of 0 wrong <ams AT ludd DOT luth DOT se>
> > ----- c.c starts. -----
> > #include <stdio.h>
> > 
> > int main(void)
> > {
> > 
> >   printf("%#08x %#08x\n", 1, 0);
> > 
> >   return 0;
> > }
> > ----- c.c ends. -----
> [snip]
> > > ./c
> > 0x000001 00000000
> > 
> > Expected result:
> > 0x000001 0x000000
> > 
> > Note how the "x" is a zero.
> 
> I think you are expecting the wrong thing. Here's what SUSv2 says about the
> '#' flag in its page about fprintf:
> 
> "#
> This flag specifies that the value is to be converted to an alternative form.
> For o conversion, it increases the precision (if necessary) to force the first
> digit of the result to be 0. For x or X conversions, a non-zero result will
> have 0x (or 0X) prefixed to it. For e, E, f, g or G conversions, the result
> will always contain a radix character, even if no digits follow the radix
> character. Without this flag, a radix character appears in the result of these
> conversions only if a digit follows it. For g and G conversions, trailing
> zeros will not be removed from the result as they normally are. For other
> conversions, the behaviour is undefined."
> 
> A draft of C99 seems to say the same thing.

Yes. The real C99 do so too. I can't see that it leaves any hole open
for printing 0x000000 instead of 00000000 either (which IMHO would be
the sensible output). Some OS (Linux?, Sun?) I tried it on, did print
0x000000, thus my bad bug report.

> So I think this report can be closed.

Yes. Unless somebody says otherwise, I'll do that in some days.


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019