Commit 25c41309b8 for perl
commit 25c41309b89487f0450d4762d40f38bc4344da38
Author: Tony Cook <tony@develop-help.com>
Date: Thu Oct 15 14:51:47 2026 +1100
Configure: default long double format to what the standard specifies
When double and long double are the same size and (presumably) the
same representation, Configure tests whether the format strings
for double work for long double, and typically they do.
But the compiler continues to warn about that mis-use under -Wformat,
resulting in warnings like:
cc -c -DPERL_CORE -fno-common -DPERL_DARWIN -DNO_THREAD_SAFE_QUERYLOCALE -DNO_POSIX_2008_LOCALE -DHAS_BROKEN_LANGINFO_CODESET -DNO_LOCALE_COLLATE -fno-strict-aliasing -pipe -fstack-protector-strong -std=c99 -O3 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wno-c++-keyword -Wwrite-strings sv.c
sv.c:3394:21: warning: format specifies type 'double' but the argument has type
'NV' (aka 'long double') [-Wformat]
3394 | SNPRINTF_G(SvNVX(sv), s, SvLEN(sv), NV_DIG);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sv.c:48:24: note: expanded from macro 'SNPRINTF_G'
48 | PERL_UNUSED_RESULT(Gconvert((NV)(nv), (int)ndig, 0, buffer))
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./config.h:914:52: note: expanded from macro 'Gconvert'
914 | #define Gconvert(x,n,t,b) sprintf((b),"%.*""g",(n),(x))
| ~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:107:55: note:
expanded from macro 'sprintf'
107 | #define sprintf(str, ...) __sprintf_chk_func (str, 0, __VA_ARGS__)
| ^~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:87:58: note:
expanded from macro '__sprintf_chk_func'
87 | __builtin___sprintf_chk (str, flag, __darwin_obsz(str), __VA_ARGS__)
| ^~~~~~~~~~~
./perl.h:807:59: note: expanded from macro 'PERL_UNUSED_RESULT'
807 | # define PERL_UNUSED_RESULT(v) STMT_START { __typeof__(v) z = (v); (v...
| ^
So check the standard correct long double format first.
diff --git a/Configure b/Configure
index 75894e0dcc..d9d26eff89 100755
--- a/Configure
+++ b/Configure
@@ -10246,13 +10246,13 @@ if $test X"$d_longdbl" = X"$define"; then
echo "Checking how to print long doubles..." >&4
-if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
+if $test X"$sPRIfldbl" = X; then
$cat >try.c <<'EOCP'
#include <sys/types.h>
#include <stdio.h>
int main() {
- double d = 123.456;
- printf("%.3f\n", d);
+ long double d = 123.456;
+ printf("%.3Lf\n", d);
}
EOCP
set try
@@ -10260,21 +10260,21 @@ EOCP
yyy=`$run ./try`
case "$yyy" in
123.456)
- sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
- sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
- echo "We will use %f."
+ sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
+ sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
+ echo "We will use %Lf."
;;
esac
fi
fi
-if $test X"$sPRIfldbl" = X; then
+if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
$cat >try.c <<'EOCP'
#include <sys/types.h>
#include <stdio.h>
int main() {
- long double d = 123.456;
- printf("%.3Lf\n", d);
+ double d = 123.456;
+ printf("%.3f\n", d);
}
EOCP
set try
@@ -10282,9 +10282,9 @@ EOCP
yyy=`$run ./try`
case "$yyy" in
123.456)
- sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
- sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
- echo "We will use %Lf."
+ sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
+ sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
+ echo "We will use %f."
;;
esac
fi