bug with printf positional arguments?
Corinna Vinschen
vinschen@redhat.com
Mon Jul 3 11:14:59 GMT 2023
On Jun 28 14:28, Jon Turney wrote:
>
> The following trivial program (extracted from a glib testcase)
>
> > #include <stdio.h>
> >
> > int main()
> > {
> > printf ("%1$*2$.*3$s", "abc", 5, 2);
> > }
>
> does not produce the expected output of " ab", on 64-bit Cygwin.
>
> From a bit of staring at and stepping through get_args() in
> libc/stdio/vfprintf.c, it looks like the problem is (something like) we
> don't have the knowledge that the first positional variadic argument should
> be treated as a pointer, at the point that we store it's value, so it gets
> treated as an integer (the default), which is going to lead to truncation on
> LP64 platforms.
>
> A straightforward way to fix this eludes me.
Can you point out where in the code this problem occurs, so maybe
we can discuss the necessary code changes in this thread?
Thanks,
Corinna
More information about the Newlib
mailing list