🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
6 messages
6 total messages Started by bugzilla-noreply Sun, 11 Oct 2026 03:55
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#59
Author: bugzilla-noreply
Date: Sun, 11 Oct 2026 03:55
69 lines
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
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#60
Author: bugzilla-noreply
Date: Sun, 11 Oct 2026 03:56
19 lines
2692 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291

--- Comment #1 from Mikhail Teterin <mi@FreeBSD.org> ---
Created attachment 275575
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275575&action=edit
Proposed fix for the problem

The proposed fix is simple to review, but it may be better to also unify the
arguments-handling for all *printf-functions.

-- 
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
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#61
Author: bugzilla-noreply
Date: Sun, 11 Oct 2026 04:02
27 lines
2985 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291

Mikhail Teterin <mi@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #275574|0                           |1
        is obsolete|                            |

--- Comment #2 from Mikhail Teterin <mi@FreeBSD.org> ---
Created attachment 275576
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275576&action=edit
Add test for the problem

The newer version of the test compares numbered against sequential output for
every conversion and length modifier, narrow and wide.

-- 
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
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#62
Author: bugzilla-noreply
Date: Sun, 11 Oct 2026 04:04
23 lines
2849 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291

Mikhail Teterin <mi@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #275575|0                           |1
        is obsolete|                            |

--- Comment #3 from Mikhail Teterin <mi@FreeBSD.org> ---
Created attachment 275577
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275577&action=edit
Proposed fix for the 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
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#63
Author: bugzilla-noreply
Date: Sun, 11 Oct 2026 04:09
25 lines
2917 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291

Mikhail Teterin <mi@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #275576|0                           |1
        is obsolete|                            |

--- Comment #4 from Mikhail Teterin <mi@FreeBSD.org> ---
Created attachment 275578
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=275578&action=edit
Add test for the problem

Avoid conflict with the subsequent (fix) patch. Sorry for the noise.

-- 
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
[Bug 299291] printf(3): numbered F-conversions broken - fetch wrong arguments
#127
Author: bugzilla-noreply
Date: Fri, 16 Oct 2026 16:20
17 lines
2686 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299291

Dag-Erling Smørgrav <des@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|bugs@FreeBSD.org            |des@FreeBSD.org
                 CC|                            |des@FreeBSD.org

-- 
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads