delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/12/07/11:35:05

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 4B7GZ4Pk105576
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 4B7GZ4Pk105576
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=ql+GvI8X
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14AF53858423
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1733589303;
bh=99joJCPjy4po8CvrnMWbH+7Yoql/mxnuz32dptf1th8=;
h=Date:Subject:To:References:Cc:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
From:Reply-To:From;
b=ql+GvI8XYCsJUUe/4f+5X8PbpCALppFRfWPpOtt34bZCL9xfhdfQ/5nhGH33GITH1
D59uyXHuziisQTWQdTBzlZ1jHHz08C65twOyyV4cIRaAjOI2g4joCbzUi53QC/2f7g
RGqpiXUY704pTCJbTnHtMg4JTjFsCPNS+yKKpSwA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46163385841C
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 46163385841C
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733589238; cv=none;
b=GIaCSEiwCrkotBgYZUOJUk6TO3GxysRjX2D5c8HyUG5nnM+pnCmefR5vUgzSfaN/QoUWzFndzQXc2SRfOdKS3Oq4i72Ca4KuRPOEfeYMeBeToiidAirx48lkdgvDrI2XTSYKhvW6i07eV2KvhZB5DAVInMm0p6rgfpzW1mJ1X/U=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1733589238; c=relaxed/simple;
bh=GQ9GB9zDGIZsQ7gTYX1FfA0aTpSgLavnLBG/JwXecDY=;
h=Message-ID:Date:MIME-Version:Subject:To:From;
b=D2SeS5uQ37idh5wEbCkx2Ok9DCicm2Mk8M1pknLaquHS/AUk+Ep9j0JZ2LqTPpsiJA2l7NC4UfPwD/Uqi0U8QugGpjksDVerbDJ/eqBQM+ijqcyE0+xmWBLf1a3MTyDd040dUQ74nrTr9oGsYqEvB0ISGI9EkfYeOwM7Ea2F7jM=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46163385841C
X-SNCR-Rigid: 674901FF00E38BFD
X-Originating-IP: [86.143.185.89]
X-OWM-Source-IP: 86.143.185.89
X-OWM-Env-Sender: jon DOT turney AT dronecode DOT org DOT uk
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgeefuddrjedugdekkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhvegjtgfgsehtjeertddtvdejnecuhfhrohhmpeflohhnucfvuhhrnhgvhicuoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqeenucggtffrrghtthgvrhhnpeeggeeuteeigeeikefgheethfetuefhtdegieeikeehteehfeefvdeuffdtveejffenucffohhmrghinhepshhouhhrtggvfigrrhgvrdhorhhgnecukfhppeekiedrudegfedrudekhedrkeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurddutdelngdpihhnvghtpeekiedrudegfedrudekhedrkeelpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdprhgvvhfkrfephhhoshhtkeeiqddugeefqddukeehqdekledrrhgrnhhgvgekiedqudegfedrsghttggvnhhtrhgrlhhplhhushdrtghomhdprghuthhhpghushgvrhepjhhonhhtuhhrnhgvhiessghtihhnthgvrhhnvghtrdgtohhmpdhgvghokffrpefiuedpoffvtefjohhsthepsghtphhrughrghhotddtkedpnhgspghrtghpthhtohepvddprhgtphht
thhopefmvghithhhrdfurdfvhhhomhhpshhonhesghhmrghilhdrtghomhdprhgtphhtthhopegthihgfihinhestgihghifihhnrdgtohhm
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-VadeSecure-score: verdict=clean score=0/300, class=clean
Message-ID: <295c1185-c839-40df-80a7-2a59a4d742ca@dronecode.org.uk>
Date: Sat, 7 Dec 2024 16:33:48 +0000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Bug in handling of "1$", "2$" in printf format
To: Keith Thompson <Keith DOT S DOT Thompson AT gmail DOT com>
References: <CAAHpriPTSi-ji2xqX_yhNbtkdX_BxBr=tzchN=Gxk4dXg3kbAw AT mail DOT gmail DOT com>
Cc: cygwin AT cygwin DOT com
In-Reply-To: <CAAHpriPTSi-ji2xqX_yhNbtkdX_BxBr=tzchN=Gxk4dXg3kbAw@mail.gmail.com>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Jon Turney via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Jon Turney <jon DOT turney AT dronecode DOT org DOT uk>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

On 07/12/2024 05:26, Keith Thompson via Cygwin wrote:
> Brian Inglis wrote:
>> On 2024-12-06 19:16, Keith Thompson via Cygwin wrote:
>>> The use of "1$", "2$" et al in printf format specifiers is a
>>> POSIX-specific feature.
>>>
>>> On Cygwin (newlib) this is handled correctly in most cases, but one
>>> example I tried misbehaves.
>>> The output is correct on other implementations, including glibc and
>>> musl on Ubuntu.
>>>
>>> This C program:
>>>
>>> #include <stdio.h>
>>> int main(void) {
>>>       long long a = 123456789876543210;
>>>       double b=1.0/3;
>>>       printf("a:%2$8.8lld b:%1$10.2g\n", b, a);
>>> }
>>>
>>> should produce this output:
>>>
>>> a:123456789876543210 b:      0.33
>>>
>>> Under Cygwin (fully updated), with "gcc c.c -o c && ./c", the output is:
>>>
>>> a:140732550844138 b:  7.1e-315
>>>
>>
>> Confirmed with gcc 12.4 and minor tweaks to constant data types: printf is
>> ignoring arg positions:
> [SNIP]
> 
> It's not always ignoring arg positions. I think there's an interaction
> between the "1$" / "2$" position specification and relatively complex
> format specifiers.  The following case works correctly:
> 
> $ cat c2.c
> #include <stdio.h>
> int main(void) {
>      int a = 42;
>      double b = 1.0/3.0;
>      printf("a:%2$d b:%1$g\n", b, a);
>      printf("a:%1$d b:%2$g\n", a, b);
>      printf("a:%d b:%g\n",     a, b);
> }
> $ gcc c2.c -o c2 && ./c2
> a:42 b:0.333333
> a:42 b:0.333333
> a:42 b:0.333333
> $
> 
> (And the version of gcc shouldn't matter.  printf is implemented in
> newlib.  The code in question should be in newlib/libc/stdio/vfprintf.c.)

Not sure if this is the same/similar/different to the problem I reported 
at [1]

[1] https://sourceware.org/pipermail/newlib/2023/020374.html


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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