develooper Front page | perl.perl5.porters | Postings from August 2019

[perl #134363] Odd warning in simple XSub (-Dusequadmath buildsonly)

Thread Next
From:
Tony Cook via RT
Date:
August 26, 2019 04:38
Subject:
[perl #134363] Odd warning in simple XSub (-Dusequadmath buildsonly)
Message ID:
rt-4.0.24-19550-1566794318-573.134363-15-0@perl.org
On Sun, 25 Aug 2019 19:21:09 -0700, jkeenan wrote:
> On Mon, 26 Aug 2019 02:14:57 GMT, tonyc wrote:
> > On Mon, 19 Aug 2019 23:44:18 -0700, sisyphus359@gmail.com wrote:
> > > OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
> > > I can't find a -Dusequadmath build on the system that doesn't issue
> > > the
> > > warning.
> > > I've tested:
> > > (v5.31.2) built for x86_64-linux-quadmath
> > > (v5.30.0) built for x86_64-linux-quadmath
> > > (v5.28.0) built for x86_64-linux-quadmath
> > > (v5.26.0) built for x86_64-linux-thread-multi-quadmath
> > > (v5.24.0) built for x86_64-linux-thread-multi-quadmath
> > > (v5.22.0) built for x86_64-linux-thread-multi-quadmath
> >
> > What I think is happening, is somehow, -Wformat is enabled by default
> > on your gcc, similarly for James.
> >
> > I don't see anything in the gcc release notes indicating that it was
> > turned on by default, but it may have been omitted.
> >
> > While building perl with a quadmath build, the build of perl itself
> > and the bundled modules includes a -Wno-format, since gcc's -Wformat
> > checks don't understand the Q size modifier.
> >
> > This addition of -Wno-format isn't used while building CPAN modules
> > after perl is installed though, so you see the warnings.
> >
> > If you want to check if format warnings are on by default, try
> > building this code:
> >
> > #include <stdio.h>
> >
> > extern __float128 x;
> >
> > void f(void) {
> >     printf("%Qf", x);
> > }
> >
> > with:
> >
> > cc -c test.c
> >
> > which doesn't warn here with gcc 6.3.0.
> >
> 
> $ uname -mrs
> Linux 4.15.0-58-generic x86_64
> 
> $ gcc --version
> gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
> 
> $ gcc -c 134363-test.c
> 134363-test.c: In function ‘f’:
> 134363-test.c:6:14: warning: unknown conversion type character ‘Q’ in
> format [-Wformat=]
>     printf("%Qf", x);
>              ^
> 134363-test.c:6:12: warning: too many arguments for format [-Wformat-
> extra-args]
>     printf("%Qf", x);
>            ^~~~~

Ubuntu seem to turn on -Wformat=2 and -Wformat-security by default, from the dist diff file:

+++ gcc-7-7.4.0/debian/patches/gcc-default-format-security.diff
@@ -0,0 +1,39 @@
+# DP: Turn on -Wformat -Wformat-security by  default for C, C++, ObjC, ObjC++.
+
+Index: b/src/gcc/doc/invoke.texi
+===================================================================
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@@ -4142,6 +4142,11 @@ value is used and that might result in t
+ sufficient length or magnitude.
+ @end table
+ 
++NOTE: In Ubuntu 8.10 and later versions this option is enabled by default
++for C, C++, ObjC, ObjC++.  To disable, use @option{-Wno-format-security},
++or disable all format warnings with @option{-Wformat=0}.  To make format
++security warnings fatal, specify @option{-Werror=format-security}.
++
+ @item -Wformat-y2k
+ @opindex Wformat-y2k
+ @opindex Wno-format-y2k
+Index: b/src/gcc/gcc.c
+===================================================================
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@@ -876,11 +876,14 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
+ #endif
+ 
++/* no separate spec, just shove it into the ssp default spec */
++#define FORMAT_SECURITY_SPEC "%{!Wformat:%{!Wformat=2:%{!Wformat=0:%{!Wall:-Wformat} %{!Wno-format-security:-Wformat-security}}}}"
++
+ #ifndef SSP_DEFAULT_SPEC
+ #if defined(TARGET_LIBC_PROVIDES_SSP) && !defined(ACCEL_COMPILER)
+-#define SSP_DEFAULT_SPEC "%{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:-fstack-protector}}}}"
++#define SSP_DEFAULT_SPEC "%{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:-fstack-protector}}}} " FORMAT_SECURITY_SPEC
+ #else
+-#define SSP_DEFAULT_SPEC ""
++#define SSP_DEFAULT_SPEC FORMAT_SECURITY_SPEC
+ #endif
+ #endif
+ 

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=134363

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About