Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"redundant argument in printf" warning and computed field widths #14772

Closed
p5pRT opened this issue Jun 23, 2015 · 9 comments
Closed

"redundant argument in printf" warning and computed field widths #14772

p5pRT opened this issue Jun 23, 2015 · 9 comments
Labels

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jun 23, 2015

Migrated from rt.perl.org#125469 (status was 'resolved')

Searchable as RT125469$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 23, 2015

From karl@freefriends.org

This is a bug report for perl from karl@​freefriends.org,
generated with the help of perlbug 1.40 running under perl 5.22.0.

The perlfunc doc (aka http​://perldoc.perl.org/functions/sprintf.html)
has this example​:

  printf '<%*2$s>', "a", 6; # prints "< a>"

Running it with perl -w, in perl 5.22.0, produces a warning​:

  Redundant argument in printf at try.pl line 1.

Maybe I'm missing something obvious, but it sure seems like both
arguments are being used; the a is the value and the 6 is the field
width. So the warning seems incorrect. Help?

Thanks,
Karl (karl@​freefriends.org)


Flags​:
  category=core
  severity=medium


Site configuration information for perl 5.22.0​:

Configured by karl at Sat Jun 13 07​:10​:09 MDT 2015.

Summary of my perl5 (revision 5 version 22 subversion 0) configuration​:
 
  Platform​:
  osname=linux, osvers=2.6.32-504.16.2.el6.x86_64, archname=x86_64-linux
  uname='linux frenzy.freefriends.org 2.6.32-504.16.2.el6.x86_64 #1 smp wed apr 22 06​:48​:29 utc 2015 x86_64 gnulinux '
  config_args='-d -e -Uinstallusrbinperl -Dprefix=/usr/local'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
  optimize='-O2',
  cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-11)', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
  libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.12'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'


@​INC for perl 5.22.0​:
  /usr/local/lib/perl5/site_perl/5.22.0/x86_64-linux
  /usr/local/lib/perl5/site_perl/5.22.0
  /usr/local/lib/perl5/5.22.0/x86_64-linux
  /usr/local/lib/perl5/5.22.0
  /usr/local/lib/perl5/site_perl/5.20.2
  /usr/local/lib/perl5/site_perl/5.20.1
  /usr/local/lib/perl5/site_perl/5.20.0
  /usr/local/lib/perl5/site_perl/5.18.2
  /usr/local/lib/perl5/site_perl/5.18.1
  /usr/local/lib/perl5/site_perl/5.16.3
  /usr/local/lib/perl5/site_perl/5.14.2
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.22.0​:
  HOME=/u/karl
  LANG (unset)
  LANGUAGE (unset)
  LC_ALL=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=.​:/u/karl/bin​:/l/bin​:/usr/local/gnu/bin​:/usr/local/bin​:/usr/X11R6/bin​:/usr/local/sbin​:/sbin​:/usr/sbin​:/usr/bin​:/bin​:/l/mailman/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 24, 2015

From @jkeenan

On Tue Jun 23 16​:01​:23 2015, karl@​freefriends.org wrote​:

This is a bug report for perl from karl@​freefriends.org,
generated with the help of perlbug 1.40 running under perl 5.22.0.

The perlfunc doc (aka http​://perldoc.perl.org/functions/sprintf.html)
has this example​:

printf '<%*2$s>', "a", 6; # prints "< a>"

Running it with perl -w, in perl 5.22.0, produces a warning​:

Redundant argument in printf at try.pl line 1.

Maybe I'm missing something obvious, but it sure seems like both
arguments are being used; the a is the value and the 6 is the field
width. So the warning seems incorrect. Help?

Thanks,
Karl (karl@​freefriends.org)

I agree.

Relevant documentation from pod/perldiag.pod and pod/perlfunc.pod (blead)​:

#####
=item Redundant argument in %s

(W redundant) You called a function with more arguments than other
arguments you supplied indicated would be needed. Currently only
emitted when a printf-type format required fewer arguments than were
supplied, but might be used in the future for e.g. L<perlfunc/pack>.
#####
Between the C<%> and the format letter, you may specify several
additional attributes controlling the interpretation of the format.
In order, these are​:

=over 4

=item format parameter index

An explicit format parameter index, such as C<2$>. By default sprintf
will format the next unused argument in the list, but this allows you
to take the arguments out of order​:

  printf '%2$d %1$d', 12, 34; # prints "34 12"
  printf '%3$d %d %1$d', 1, 2, 3; # prints "3 1 1"
...
=item (minimum) width

Arguments are usually formatted to be only as wide as required to
display the given value. You can override the width by putting
a number here, or get the width from the next argument (with C<*>)
or from a specified argument (e.g., with C<*2$>)​:

printf "<%s>", "a"; # prints "<a>"
printf "<%6s>", "a"; # prints "< a>"
printf "<%*s>", 6, "a"; # prints "< a>"
printf '<%*2$s>', "a", 6; # prints "< a>"
printf "<%2s>", "long"; # prints "<long>" (does not truncate)
#####
Thank you very much.
Jim Keenan

---
Flags​:
category=core
severity=medium
---
Site configuration information for perl 5.22.0​:

Configured by karl at Sat Jun 13 07​:10​:09 MDT 2015.

Summary of my perl5 (revision 5 version 22 subversion 0)
configuration​:

Platform​:
osname=linux, osvers=2.6.32-504.16.2.el6.x86_64, archname=x86_64-
linux
uname='linux frenzy.freefriends.org 2.6.32-504.16.2.el6.x86_64 #1
smp wed apr 22 06​:48​:29 utc 2015 x86_64 gnulinux '
config_args='-d -e -Uinstallusrbinperl -Dprefix=/usr/local'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-
protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
optimize='-O2',
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-11)',
gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678,
doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16,
longdblkind=3
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
/lib64 /usr/lib64 /usr/local/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.12'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-
protector'

---
@​INC for perl 5.22.0​:
/usr/local/lib/perl5/site_perl/5.22.0/x86_64-linux
/usr/local/lib/perl5/site_perl/5.22.0
/usr/local/lib/perl5/5.22.0/x86_64-linux
/usr/local/lib/perl5/5.22.0
/usr/local/lib/perl5/site_perl/5.20.2
/usr/local/lib/perl5/site_perl/5.20.1
/usr/local/lib/perl5/site_perl/5.20.0
/usr/local/lib/perl5/site_perl/5.18.2
/usr/local/lib/perl5/site_perl/5.18.1
/usr/local/lib/perl5/site_perl/5.16.3
/usr/local/lib/perl5/site_perl/5.14.2
/usr/local/lib/perl5/site_perl
.

---
Environment for perl 5.22.0​:
HOME=/u/karl
LANG (unset)
LANGUAGE (unset)
LC_ALL=C
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=.​:/u/karl/bin​:/l/bin​:/usr/local/gnu/bin​:/usr/local/bin​:/usr/X11R6/bin​:/usr/local/sbin​:/sbin​:/usr/sbin​:/usr/bin​:/bin​:/l/mailman/bin
PERL_BADLANG (unset)
SHELL=/bin/bash

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 24, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 29, 2015

From @arc

via RT <perlbug-followup@​perl.org> wrote​:

The perlfunc doc (aka http​://perldoc.perl.org/functions/sprintf.html)
has this example​:

printf '<%*2$s>', "a", 6; # prints "< a>"

Running it with perl -w, in perl 5.22.0, produces a warning​:

Redundant argument in printf at try.pl line 1.

Maybe I'm missing something obvious, but it sure seems like both
arguments are being used; the a is the value and the 6 is the field
width. So the warning seems incorrect. Help?

Thanks for the report. I agree that it's incorrect for Perl to emit
this warning.

This patch against blead is currently smoking as smoke-me/arc/rt125469​:

From​: Aaron Crane <arc@​cpan.org>
Date​: Mon, 29 Jun 2015 16​:35​:11 +0100
Subject​: [PATCH] sv_vcatpvfn_flags()​: make warnings more precise

- RT#125469 points out that no "redundant argument" warning should be emitted
  for code like C<< printf '<%*2$s>', "a", 6 >>; that's now fixed.

- We no longer emit a "missing argument" warning for invalid format strings,
  so C<< printf '%4$K %d', 17 >> now emits one "invalid" warning, and no
  other warnings. (Perl 5.12 and subsequent versions have inappropriately
  emitted a "missing argument" warning in this case.)

- We no longer treat the invalid format string in C<< printf '%1$$d', 17 >>
  as containing an explicit index, so (a) we emit an "invalid" warning for
  the double "$", and (b) we emit a "redundant argument" warning for the
  trailing argument. The "redundant argument" warning is new in this
  situation.


sv.c | 65 ++++++++++++++++++++++++++++++++++++----------------------
t/op/sprintf.t | 9 ++++----
2 files changed, 46 insertions(+), 28 deletions(-)

Inline Patch
diff --git a/sv.c b/sv.c
index b4a36e5..d3debba 100644
--- a/sv.c
+++ b/sv.c
@@ -10594,16 +10594,16 @@ Perl_sv_vsetpvfn(pTHX_ SV *const sv, const
char *const pat, const STRLEN patlen,

/*
- * Warn of missing argument to sprintf, and then return a defined value
- * to avoid inappropriate "use of uninit" warnings [perl #71000].
+ * Warn of missing argument to sprintf. The value used in place of such
+ * arguments should be &PL_sv_no; an undefined value would yield
+ * inappropriate "use of uninit" warnings [perl #71000].
  */
-STATIC SV*
-S_vcatpvfn_missing_argument(pTHX) {
+STATIC void
+S_warn_vcatpvfn_missing_argument(pTHX) {
  if (ckWARN(WARN_MISSING)) {
  Perl_warner(aTHX_ packWARN(WARN_MISSING), "Missing argument in %s",
  PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
  }
- return &PL_sv_no;
}

@​@​ -11032,6 +11032,17 @​@​ S_hextract(pTHX_ const NV nv, int* exponent,
U8* vhex, U8* vend)
  return v;
}

+/* Helper for sv_vcatpvfn_flags(). */
+#define FETCH_VCATPVFN_ARGUMENT(var, in_range, expr) \
+ STMT_START { \
+ if (in_range) \
+ (var) = (expr); \
+ else { \
+ (var) = &PL_sv_no; /* [perl #71000] */ \
+ arg_missing = TRUE; \
+ } \
+ } STMT_END
+
void
Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat,
const STRLEN patlen,
  va_list *const args, SV **const svargs, const
I32 svmax, bool *const maybe_tainted,
@​@​ -11087,7 +11098,7 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  sv_catsv_nomg(sv, *svargs);
  }
  else
- S_vcatpvfn_missing_argument(aTHX);
+ S_warn_vcatpvfn_missing_argument(aTHX);
  return;
  }
  if (args && patlen == 3 && pat[0] == '%' &&
@​@​ -11161,6 +11172,8 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  STRLEN precis = 0;
  const I32 osvix = svix;
  bool is_utf8 = FALSE; /* is this item utf8? */
+ bool used_explicit_ix = FALSE;
+ bool arg_missing = FALSE;
#ifdef HAS_LDBL_SPRINTF_BUG
  /* This is to try to fix a bug with irix/nonstop-ux/powerux and
  with sfio - Allen <allens@​cpan.org> */
@​@​ -11326,11 +11339,7 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  if (*q == '$') {
  ++q;
  efix = width;
- if (!no_redundant_warning)
- /* I've forgotten if it's a better
- micro-optimization to always set this or to
- only set it if it's unset */
- no_redundant_warning = TRUE;
+ used_explicit_ix = TRUE;
  } else {
  goto gotwidth;
  }
@​@​ -11371,9 +11380,12 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  tryasterisk​:
  if (*q == '*') {
  q++;
- if ( (ewix = expect_number(&q)) )
- if (*q++ != '$')
+ if ( (ewix = expect_number(&q)) ) {
+ if (*q++ == '$')
+ used_explicit_ix = TRUE;
+ else
  goto unknown;
+ }
  asterisk = TRUE;
  }
  if (*q == 'v') {
@​@​ -11401,11 +11413,11 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  if (args)
  vecsv = va_arg(*args, SV*);
  else if (evix) {
- vecsv = (evix > 0 && evix <= svmax)
- ? svargs[evix-1] : S_vcatpvfn_missing_argument(aTHX);
+ FETCH_VCATPVFN_ARGUMENT(
+ vecsv, evix > 0 && evix <= svmax, svargs[evix-1]);
  } else {
- vecsv = svix < svmax
- ? svargs[svix++] : S_vcatpvfn_missing_argument(aTHX);
+ FETCH_VCATPVFN_ARGUMENT(
+ vecsv, svix < svmax, svargs[svix++]);
  }
  dotstr = SvPV_const(vecsv, dotstrlen);
  /* Keep the DO_UTF8 test *after* the SvPV call, else things go
@​@​ -11573,11 +11585,10 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  if (!vectorize && !args) {
  if (efix) {
  const I32 i = efix-1;
- argsv = (i >= 0 && i < svmax)
- ? svargs[i] : S_vcatpvfn_missing_argument(aTHX);
+ FETCH_VCATPVFN_ARGUMENT(argsv, i >= 0 && i < svmax, svargs[i]);
  } else {
- argsv = (svix >= 0 && svix < svmax)
- ? svargs[svix++] : S_vcatpvfn_missing_argument(aTHX);
+ FETCH_VCATPVFN_ARGUMENT(argsv, svix >= 0 && svix < svmax,
+ svargs[svix++]);
  }
  }

@​@​ -11680,7 +11691,7 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  if (vectorize) {
  STRLEN ulen;
  if (!veclen)
- continue;
+ goto donevalidconversion;
  if (vec_utf8)
  uv = utf8n_to_uvchr(vecstr, veclen, &ulen,
  UTF8_ALLOW_ANYUV);
@​@​ -11785,7 +11796,7 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  STRLEN ulen;
  vector​:
  if (!veclen)
- continue;
+ goto donevalidconversion;
  if (vec_utf8)
  uv = utf8n_to_uvchr(vecstr, veclen, &ulen,
  UTF8_ALLOW_ANYUV);
@​@​ -12447,7 +12458,7 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  }
  else
  sv_setuv_mg(argsv, has_utf8 ? (UV)sv_len_utf8(sv) : (UV)i);
- continue; /* not "break" */
+ goto donevalidconversion;

  /* UNKNOWN */

@​@​ -12572,6 +12583,12 @​@​ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p
  esignlen = 0;
  goto vector;
  }
+
+ donevalidconversion​:
+ if (used_explicit_ix)
+ no_redundant_warning = TRUE;
+ if (arg_missing)
+ S_warn_vcatpvfn_missing_argument(aTHX);
  }

  /* Now that we've consumed all our printf format arguments (svix)

Inline Patch
diff --git a/t/op/sprintf.t b/t/op/sprintf.t
index c927a94..e11287c 100644
--- a/t/op/sprintf.t
+++ b/t/op/sprintf.t
@@ -647,7 +647,8 @@ __END__
 >%y<        >''<          >%y INVALID REDUNDANT<
 >%z<        >''<          >%z INVALID REDUNDANT<
 >%2$d %1$d< >[12, 34]< >34 12<
->%*2$d< >[12, 3]< > 12 REDUNDANT<
+>%*2$d< >[12, 3]< > 12<             >RT#125469<
+>%*3$d< >[12, 9, 3]< > 12<             >related to RT#125469<
 >%2$d %d< >[12, 34]< >34 12<
 >%2$d %d %d< >[12, 34]< >34 12 34<
 >%3$d %d %d< >[12, 34, 56]< >56 12 34<
@@ -655,8 +656,8 @@ __END__
 >%*3$2$d %d< >[12, 34, 3]< >%*3$2$d 12 INVALID REDUNDANT<
 >%2$d< >12< >0 MISSING<
 >%0$d< >12< >%0$d INVALID REDUNDANT<
->%1$$d< >12< >%1$$d INVALID<
->%1$1$d< >12< >%1$1$d INVALID<
+>%1$$d< >12< >%1$$d INVALID REDUNDANT<
+>%1$1$d< >12< >%1$1$d INVALID REDUNDANT<
 >%*2$*2$d< >[12, 3]< >%*2$*2$d INVALID REDUNDANT<
 >%*2*2$d< >[12, 3]< >%*2*2$d INVALID REDUNDANT<
 >%*2$1d< >[12, 3]< >%*2$1d INVALID REDUNDANT<
@@ -713,7 +714,7 @@ __END__
 >%V-%s< >["Hello"]< >%V-Hello INVALID<
 >%K %d %d< >[13, 29]< >%K 13 29 INVALID<
 >%*.*K %d< >[13, 29, 76]< >%*.*K 13 INVALID REDUNDANT<
->%4$K %d< >[45, 67]< >%4$K 45 MISSING INVALID<
+>%4$K %d< >[45, 67]< >%4$K 45 INVALID REDUNDANT<
 >%d %K %d< >[23, 45]< >23 %K 45 INVALID<
 >%*v*999\$d %d %d< >[11, 22, 33]< >%*v*999\$d 11 22 INVALID REDUNDANT<
 >%#b< >0< >0<


I also believe that this bug is a regression that warrants a fix in maint\, hopefully to be released as part of 5\.22\.1\. However\, my blead patch is unsuitable for that purpose\, as it will also yield additional warnings for some other code\. \(It ensures that an invalid format specification is never treated as containing an explicit argument index\, so code like C\<\< printf '%1$$d'\, 17 >> will get a "redundant" warning for the 17\, as well as an "invalid" warning for the malformed '%1$$d'\.\) So I'm also smoking this simpler patch as smoke\-me/arc/rt125469\-maint\, in the expectation that it could be applied to maint​:

From​: Aaron Crane <arc@​cpan.org>
Date​: Mon, 29 Jun 2015 16​:55​:14 +0100
Subject​: [PATCH] sv_vcatpvfn_flags()​: no "redundant arg" warnings for '%*2$d'

This addresses RT#125469​: if the format string uses an explicit index for a
field width, that should suppress any "redundant argument" warnings, in
just the same way as an explicit index does when used to specify a format
argument.

Blead has a more careful reworking of the way printf warnings work, but that
change is unsuitable for maint, as it can lead to additional warnings being
emitted for some invalid format strings. This smaller change ensures that
maint (5.22.1-to-be) always emits strictly fewer warnings than 5.22.0.


sv.c | 7 +++++--
t/op/sprintf.t | 9 +++++----
2 files changed, 10 insertions(+), 6 deletions(-)

Inline Patch
diff --git a/sv.c b/sv.c
index 8440763..6afc5a6 100644
--- a/sv.c
+++ b/sv.c
@@ -11522,9 +11522,12 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv,
const char *const pat, const STRLEN p   tryasterisk​:   if \(\*q == '\*'\) \{   q\+\+; \- if \( \(ewix = expect\_number\(&q\)\) \) \- if \(\*q\+\+ \!= '$'\) \+ if \( \(ewix = expect\_number\(&q\)\) \) \{ \+ if \(\*q\+\+ == '$'\) \+ no\_redundant\_warning = TRUE; \+ else   goto unknown; \+ \}   asterisk = TRUE;   \}   if \(\*q == 'v'\) \{
Inline Patch
diff --git a/t/op/sprintf.t b/t/op/sprintf.t
index 967b5d3..e6ef617 100644
--- a/t/op/sprintf.t
+++ b/t/op/sprintf.t
@@ -647,19 +647,20 @@ __END__
 >%y<        >''<          >%y INVALID REDUNDANT<
 >%z<        >''<          >%z INVALID REDUNDANT<
 >%2$d %1$d< >[12, 34]< >34 12<
->%*2$d< >[12, 3]< > 12 REDUNDANT<
+>%*2$d< >[12, 3]< > 12<             >RT#125469<
+>%*3$d< >[12, 9, 3]< > 12<             >related to RT#125469<
 >%2$d %d< >[12, 34]< >34 12<
 >%2$d %d %d< >[12, 34]< >34 12 34<
 >%3$d %d %d< >[12, 34, 56]< >56 12 34<
 >%2$*3$d %d< >[12, 34, 3]< > 34 12<
->%*3$2$d %d< >[12, 34, 3]< >%*3$2$d 12 INVALID REDUNDANT<
+>%*3$2$d %d< >[12, 34, 3]< >%*3$2$d 12 INVALID<
 >%2$d< >12< >0 MISSING<
 >%0$d< >12< >%0$d INVALID REDUNDANT<
 >%1$$d< >12< >%1$$d INVALID<
 >%1$1$d< >12< >%1$1$d INVALID<
->%*2$*2$d< >[12, 3]< >%*2$*2$d INVALID REDUNDANT<
+>%*2$*2$d< >[12, 3]< >%*2$*2$d INVALID<
 >%*2*2$d< >[12, 3]< >%*2*2$d INVALID REDUNDANT<
->%*2$1d< >[12, 3]< >%*2$1d INVALID REDUNDANT<
+>%*2$1d< >[12, 3]< >%*2$1d INVALID<
 >%0v2.2d< >''< ><
 >%vc,%d< >[63, 64, 65]< >%vc,63 INVALID REDUNDANT<
 >%v%,%d< >[63, 64, 65]< >%v%,63 INVALID REDUNDANT<

-- 

Aaron Crane ** http​://aaroncrane.co.uk/

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 8, 2015

From @steve-m-hay

On Mon Jun 29 09​:02​:52 2015, arc wrote​:

I also believe that this bug is a regression that warrants a fix in
maint, hopefully to be released as part of 5.22.1. However, my blead
patch is unsuitable for that purpose, as it will also yield additional
warnings for some other code. (It ensures that an invalid format
specification is never treated as containing an explicit argument
index, so code like C<< printf '%1$$d', 17 >> will get a "redundant"
warning for the 17, as well as an "invalid" warning for the malformed
'%1$$d'.) So I'm also smoking this simpler patch as
smoke-me/arc/rt125469-maint, in the expectation that it could be
applied to maint​:

This has now been applied to maint-5.22, ready for release in 5.22.1, by the following commit​:

http​://perl5.git.perl.org/perl.git/commit/802475c8d28a32d1dfca9e93e7c06560c1483093

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 8, 2015

From @steve-m-hay

On Thu Oct 08 09​:57​:56 2015, shay wrote​:

On Mon Jun 29 09​:02​:52 2015, arc wrote​:

I also believe that this bug is a regression that warrants a fix in
maint, hopefully to be released as part of 5.22.1. However, my blead
patch is unsuitable for that purpose, as it will also yield
additional
warnings for some other code. (It ensures that an invalid format
specification is never treated as containing an explicit argument
index, so code like C<< printf '%1$$d', 17 >> will get a "redundant"
warning for the 17, as well as an "invalid" warning for the malformed
'%1$$d'.) So I'm also smoking this simpler patch as
smoke-me/arc/rt125469-maint, in the expectation that it could be
applied to maint​:

This has now been applied to maint-5.22, ready for release in 5.22.1,
by the following commit​:

http​://perl5.git.perl.org/perl.git/commit/802475c8d28a32d1dfca9e93e7c06560c1483093

And it looks like the blead change was applied to blead a while back by this commit​:

http​://perl5.git.perl.org/perl.git/commit/082ce9c667e6d73783164fa1abab61806b678b4f

I'm therefore changing the status to 'pending release'.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 8, 2015

@steve-m-hay - Status changed from 'open' to 'pending release'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 13, 2016

From @khwilliamson

Thank you for submitting this report. You have helped make Perl better.
 
With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved.

Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented May 13, 2016

@khwilliamson - Status changed from 'pending release' to 'resolved'

@p5pRT p5pRT closed this May 13, 2016
@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.