Article View: muc.lists.freebsd.bugs
Article #59[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
From: bugzilla-noreply
Date: Sun, 11 Oct 2026 03:55
Date: Sun, 11 Oct 2026 03:55
69 lines
4144 bytes
4144 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291
Bug ID: 299291
Summary: printf(3): numbered F-conversions broken - fetch wrong
arguments
Product: Base System
Version: CURRENT
Hardware: Any
URL: https://pubs.opengroup.org/onlinepubs/9799919799/funct
ions/fprintf.html
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: mi@FreeBSD.org
Created attachment 275574
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275574&action=edit
Add test for the problem
POSIX defines the F conversion as f except for the case of INF and NAN,
and allows every conversion to be written in the numbered form "%n$":
https://pubs.opengroup.org/onlinepubs/9799919799/functions/fprintf.html
A numbered F conversion makes printf(3) and wprintf(3) read the double,
and every argument after it, from the wrong place:
#include <stdio.h>
#include <wchar.h>
int
main(void)
{
wchar_t w[64];
printf("%1$f %2$d\n", 1.5, 7); /* 1.500000 7 */
printf("%1$F %2$d\n", 1.5, 7); /* should be the same */
swprintf(w, 64, L"%1$F %2$d", 1.5, 7);
printf("%ls\n", w); /* should be the same */
return (0);
}
$ cc -o repro-printf repro-printf.c && ./repro-printf
1.500000 7
1.500000 552331777
0.000000 597837128
%1$e, %1$E, %1$f, %1$g, %1$G, %1$a and %1$A all work.
The __find_arguments() and __find_warguments in
lib/libc/stdio/printf-pos.c, have no case for 'F', so the double is never
recorded. vfprintf.c itself handles 'F' together with 'f' -- and works
correctly. Maybe, the arguments-parsing should be unified for all *printf
functions.
For reference, OpenBSD seems to not have this problem.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-299291-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments Date: Sun, 11 Oct 2026 03:55:23 +0000 Organization: Newsgate at muc.de e.V. Sender: owner-freebsd-bugs@FreeBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <bug-299291-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="27359"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791690923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9KbYGbVda+vaCB9ew4IfGcOdi0O1V0H+opAVQBGbHV8=; b=ocC4gKdozPIb5kWa2HQJg5I3EwEoBTVs/nZcjajc6XQv3ddgxqP6qYk1xmLFDMeHtXH6eJ B0MkTtJvp8+6r/3di6UCcoNqFx33t5+NQiEBOPMhhl2pKHVetqlJFI+TP+2Sl0tBINia5y AclXa30YF4MJadCjD9IQNR/BJtYCocw81D3o/qBg1e37spMQZxWeUGx5Xk7XIypaJnTGzF 1NNtU8KiC6lnZOODRfHenGU2b1XnK0evKdSrwDk7E6rH/9mtlcjiZE7QamxTaSSZAEX92+ IK5LXU5rsWub7hDISVE9olX2KzmiXuycXhhMtLWEIJUg4/wHC0cOnU8qekCyXQ== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes