From: Martin Stromberg 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Precedence: bulk Richard said: > > 08/03/2002 16:31:03: Create 000354:2.03 printf()'s %#08x handling of 0 wrong > > ----- c.c starts. ----- > > #include > > > > 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