summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorsisyphus <sisyphus@cpan.org>2020-10-21 10:52:53 +1100
committerKarl Williamson <khw@cpan.org>2020-12-27 12:09:06 -0700
commit760f7304f745da0fc8198aee516dd0e583bd59d6 (patch)
tree7bf73dcf8dda041b26487c32536a9e175da2215a /sv.c
parentcfc95b5630c63927ab68bb4cdc08b1dec23c5569 (diff)
downloadperl-760f7304f745da0fc8198aee516dd0e583bd59d6.tar.gz
sv.c - suppress bogus -Wformat-overflow warnings (Issue 18170)
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index 682656f630..ed0b6bdd30 100644
--- a/sv.c
+++ b/sv.c
@@ -13058,10 +13058,15 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
&& precis /* See earlier comment about buggy Gconvert
when digits, aka precis, is 0 */
&& has_precis
- /* check, in manner not involving wrapping, that it will
- * fit in ebuf */
- && float_need < sizeof(ebuf)
+ /* check that "%.<number>g" formatting will fit in ebuf */
&& sizeof(ebuf) - float_need > precis
+ /* sizeof(ebuf) - float_need will have wrapped if float_need > sizeof(ebuf). *
+ * Therefore we should check that float_need < sizeof(ebuf). Normally, we would *
+ * have run this check first, but that triggers incorrect -Wformat-overflow *
+ * compilation warnings with some versions of gcc if Gconvert invokes sprintf(). *
+ * ( See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89161 ) *
+ * So, instead, we check it next: */
+ && float_need < sizeof(ebuf)
&& !(width || left || plus || alt)
&& !fill
&& intsize != 'q'