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

New compilation warnings with gcc 8.3.0 #17013

Closed
p5pRT opened this issue May 23, 2019 · 11 comments
Closed

New compilation warnings with gcc 8.3.0 #17013

p5pRT opened this issue May 23, 2019 · 11 comments
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 type-core

Comments

@p5pRT
Copy link

p5pRT commented May 23, 2019

Migrated from rt.perl.org#134129 (status was 'open')

Searchable as RT134129$

@p5pRT
Copy link
Author

p5pRT commented May 23, 2019

From @dur-randir

Created by @dur-randir

I get the following warnings when building perl on Debian with gcc
8.3.0. Wimplicit-fallthrough is from at least 7.4.0, others are new
ones​:

Wcast-function-type (some of them, all are about signal handlers)​:

perl.c​: In function ‘Perl_sys_init’​:
perl.h​:2688​:51​: warning​: cast between incompatible function types from
‘__sighandler_t’ {aka ‘void (*)(int)’} to ‘void (*)(int, siginfo_t *,
void *)’ {aka ‘void (*)(int, struct <anonymous> *, void *)’}
[-Wcast-function-type]
# define PERL_FPU_INIT PL_sigfpe_saved = (Sighandler_t)
signal(SIGFPE, SIG_IGN)
  ^
unixish.h​:150​:29​: note​: in expansion of macro ‘PERL_FPU_INIT’
  MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT
  ^~~~~~~~~~~~~
perl.c​:125​:5​: note​: in expansion of macro ‘PERL_SYS_INIT_BODY’
  PERL_SYS_INIT_BODY(argc, argv);
  ^~~~~~~~~~~~~~~~~~

perl.c​: In function ‘S_parse_body’​:
perl.c​:2399​:22​: warning​: cast between incompatible function types from
‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka ‘void
(*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
  if (sigstate == (Sighandler_t) SIG_IGN) {
  ^
In file included from perl.h​:5359,
  from perl.c​:37​:
perl.c​:2402​:26​: warning​: cast between incompatible function types from
‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka ‘void
(*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
  (void)rsignal(SIGCHLD, (Sighandler_t)SIG_DFL);
  ^
embed.h​:643​:44​: note​: in definition of macro ‘rsignal’
#define rsignal(a,b) Perl_rsignal(aTHX_ a,b)

util.c​: In function ‘Perl_rsignal’​:
util.c​:2698​:22​: warning​: cast between incompatible function types from
‘Sighandler_t’ {aka ‘void (*)(int, struct <anonymous> *, void *)’} to
‘void (*)(int)’ [-Wcast-function-type]
  act.sa_handler = (void(*)(int))handler;
  ^

pp_sys.c​: In function ‘Perl_pp_system’​:
pp_sys.c​:4421​:28​: warning​: cast between incompatible function types
from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka
‘void (*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
  rsignal_save(SIGINT, (Sighandler_t) SIG_IGN, &ihand);
  ^
embed.h​:1560​:55​: note​: in definition of macro ‘rsignal_save’
#define rsignal_save(a,b,c) Perl_rsignal_save(aTHX_ a,b,c)
  ^
Wimplicit-fallthrough​:

decompress.c​: In function ‘BZ2_decompress’​:
decompress.c​:198​:10​: warning​: this statement may fall through
[-Wimplicit-fallthrough=]
  if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
  ^
decompress.c​:44​:4​: note​: here
  case lll​: s->state = lll; \
  ^~~~
decompress.c​:68​:4​: note​: in expansion of macro ‘GET_BITS’
  GET_BITS(lll,uuu,8)
  ^~~~~~~~
decompress.c​:200​:7​: note​: in expansion of macro ‘GET_UCHAR’
  GET_UCHAR(BZ_X_MAGIC_2, uc);
  ^~~~~~~~~

Wmultistatement-macros​:

deflate.c​: In function ‘deflateParams’​:
deflate.c​:602​:28​: warning​: macro expands to multiple statements
[-Wmultistatement-macros]
  CLEAR_HASH(s);
  ^
deflate.c​:193​:5​: note​: in definition of macro ‘CLEAR_HASH’
  s->head[s->hash_size-1] = NIL; \
  ^
deflate.c​:601​:13​: note​: some parts of macro expansion are not guarded
by this ‘else’ clause
  else
  ^~~~

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.31.0:

Configured by dur-randir at Wed Feb 27 14:51:01 MSK 2019.

Summary of my perl5 (revision 5 version 31 subversion 0) configuration:
  Commit id: 58f4626762668e1c1948832073998af84b2c85d0
  Platform:
    osname=linux
    osvers=4.19.0-5-amd64
    archname=x86_64-linux
    uname='linux dorothy 4.19.0-5-amd64 #1 smp debian 4.19.37-3
(2019-05-15) x86_64 gnulinux '
    config_args='-de -Dusedevel -DDEBUGGING -Dcc=gcc-8'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc-8'
    ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2 -g'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='8.3.0'
    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='gcc-8'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib
/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu
/lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.28.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.28'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl):
  Compile-time options:
    DEBUGGING
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at May 23 2019 11:40:52
  %ENV:
    PERLBREW_BASHRC_VERSION="0.78"
    PERLBREW_HOME="/home/afl/.perlbrew"
    PERLBREW_MANPATH="/home/afl/perlbrew/perls/perl-5.20.2/man"
    PERLBREW_PATH="/home/afl/perlbrew/bin:/home/afl/perlbrew/perls/perl-5.20.2/bin"
    PERLBREW_PERL="perl-5.20.2"
    PERLBREW_ROOT="/home/afl/perlbrew"
    PERLBREW_VERSION="0.78"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.31.0/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.31.0
    /usr/local/lib/perl5/5.31.0/x86_64-linux
    /usr/local/lib/perl5/5.31.0

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2019

From @jkeenan

On Thu, 23 May 2019 09​:13​:12 GMT, randir wrote​:

This is a bug report for perl from sergey.aleynikov@​gmail.com,
generated with the help of perlbug 1.41 running under perl 5.31.0.

-----------------------------------------------------------------
[Please describe your issue here]

I get the following warnings when building perl on Debian with gcc
8.3.0. Wimplicit-fallthrough is from at least 7.4.0, others are new
ones​:

Wcast-function-type (some of them, all are about signal handlers)​:

perl.c​: In function ‘Perl_sys_init’​:
perl.h​:2688​:51​: warning​: cast between incompatible function types from
‘__sighandler_t’ {aka ‘void (*)(int)’} to ‘void (*)(int, siginfo_t *,
void *)’ {aka ‘void (*)(int, struct <anonymous> *, void *)’}
[-Wcast-function-type]
# define PERL_FPU_INIT PL_sigfpe_saved = (Sighandler_t)
signal(SIGFPE, SIG_IGN)
^
unixish.h​:150​:29​: note​: in expansion of macro ‘PERL_FPU_INIT’
MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT
^~~~~~~~~~~~~
perl.c​:125​:5​: note​: in expansion of macro ‘PERL_SYS_INIT_BODY’
PERL_SYS_INIT_BODY(argc, argv);
^~~~~~~~~~~~~~~~~~

perl.c​: In function ‘S_parse_body’​:
perl.c​:2399​:22​: warning​: cast between incompatible function types from
‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka ‘void
(*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
if (sigstate == (Sighandler_t) SIG_IGN) {
^
In file included from perl.h​:5359,
from perl.c​:37​:
perl.c​:2402​:26​: warning​: cast between incompatible function types from
‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka ‘void
(*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
(void)rsignal(SIGCHLD, (Sighandler_t)SIG_DFL);
^
embed.h​:643​:44​: note​: in definition of macro ‘rsignal’
#define rsignal(a,b) Perl_rsignal(aTHX_ a,b)

util.c​: In function ‘Perl_rsignal’​:
util.c​:2698​:22​: warning​: cast between incompatible function types from
‘Sighandler_t’ {aka ‘void (*)(int, struct <anonymous> *, void *)’} to
‘void (*)(int)’ [-Wcast-function-type]
act.sa_handler = (void(*)(int))handler;
^

pp_sys.c​: In function ‘Perl_pp_system’​:
pp_sys.c​:4421​:28​: warning​: cast between incompatible function types
from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t *, void *)’ {aka
‘void (*)(int, struct <anonymous> *, void *)’} [-Wcast-function-type]
rsignal_save(SIGINT, (Sighandler_t) SIG_IGN, &ihand);
^
embed.h​:1560​:55​: note​: in definition of macro ‘rsignal_save’
#define rsignal_save(a,b,c) Perl_rsignal_save(aTHX_ a,b,c)
^
Wimplicit-fallthrough​:

decompress.c​: In function ‘BZ2_decompress’​:
decompress.c​:198​:10​: warning​: this statement may fall through
[-Wimplicit-fallthrough=]
if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
^
decompress.c​:44​:4​: note​: here
case lll​: s->state = lll; \
^~~~
decompress.c​:68​:4​: note​: in expansion of macro ‘GET_BITS’
GET_BITS(lll,uuu,8)
^~~~~~~~
decompress.c​:200​:7​: note​: in expansion of macro ‘GET_UCHAR’
GET_UCHAR(BZ_X_MAGIC_2, uc);
^~~~~~~~~

Wmultistatement-macros​:

deflate.c​: In function ‘deflateParams’​:
deflate.c​:602​:28​: warning​: macro expands to multiple statements
[-Wmultistatement-macros]
CLEAR_HASH(s);
^
deflate.c​:193​:5​: note​: in definition of macro ‘CLEAR_HASH’
s->head[s->hash_size-1] = NIL; \
^
deflate.c​:601​:13​: note​: some parts of macro expansion are not guarded
by this ‘else’ clause
else
^~~~

Thank you for this analysis. Some of these warnings are from modules that are maintained upstream on CPAN. In the case of, say, decompress.c, that's part of IO-Compress, whose maintainer has previously indicated that he modifies that code if and when the underlying C libraries get updated. So we (p5p) can't directly control that.

However, if you are able to submit patches for the warnings being emitted by those files maintained by p5p (e.g., perl.c, util.c), we would be happy to consider them.

Thank you very much.

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

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2019

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

@jkeenan jkeenan added the build-time-warnings Replaces [META] Build-time warnings RT #133556 label Nov 4, 2019
@jkeenan
Copy link
Contributor

jkeenan commented Nov 16, 2019

From @jkeenan

On Thu, 23 May 2019 09​:13​:12 GMT, randir wrote​:

[snip]

I get the following warnings when building perl on Debian with gcc
8.3.0. Wimplicit-fallthrough is from at least 7.4.0, others are new
ones​:
Wcast-function-type (some of them, all are about signal handlers)​:

[snip]

Thank you for this analysis. Some of these warnings are from modules that are maintained upstream on CPAN. In the case of, say, decompress.c, that's part of IO-Compress, whose maintainer has previously indicated that he modifies that code if and when the underlying C libraries get updated. So we (p5p) can't directly control that.

However, if you are able to submit patches for the warnings being emitted by those files maintained by p5p (e.g., perl.c, util.c), we would be happy to consider them.

Thank you very much.

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

For anyone who wants to take a go at clearing up some of these warnings, please see the attachment which lists all the Wcast-function-type warnings, all of which are in files under p5p maintenance.

Thank you very much.
Jim Keenan
make.0463f3a1.linux.gcc-8.Wcast-function-type.warnings.txt

@xenu
Copy link
Member

xenu commented Nov 16, 2019

@jkeenan
Copy link
Contributor

jkeenan commented Nov 16, 2019

@iabyn is working on this, see https://www.nntp.perl.org/group/perl.perl5.porters/2019/11/msg256570.html

Thanks for letting me know this. Yes, when that is merged, it will eliminate that particular group of warnings.

$ report-build-warnings make.0463f3a1.linux.gcc-8.output.txt.gz 
File:  make.0463f3a1.linux.gcc-8.output.txt.gz

  Wcast-function-type                       23
  Wimplicit-fallthrough=                    34
  Wmultistatement-macros                     1
  Wunused-but-set-variable                   1
  Wunused-parameter                          2
  Wunused-variable                           4

$ report-build-warnings make.sighandler2.linux.gcc-8.output.txt.gz 
File:  make.sighandler2.linux.gcc-8.output.txt.gz

  Wimplicit-fallthrough=                    34
  Wmultistatement-macros                     1
  Wunused-but-set-variable                   1
  Wunused-parameter                          2
  Wunused-variable                           4

@pmqs
Copy link
Contributor

pmqs commented Nov 21, 2019

From @jkeenan

On Thu, 23 May 2019 09​:13​:12 GMT, randir wrote​:

This is a bug report for perl from sergey.aleynikov@​gmail.com,
generated with the help of perlbug 1.41 running under perl 5.31.0.

[Please describe your issue here]
I get the following warnings when building perl on Debian with gcc
8.3.0. Wimplicit-fallthrough is from at least 7.4.0, others are new
ones​:
...

Thank you for this analysis. Some of these warnings are from modules that are maintained upstream on CPAN. In the case of, say, decompress.c, that's part of IO-Compress, whose maintainer has previously indicated that he modifies that code if and when the underlying C libraries get updated. So we (p5p) can't directly control that.

That had been my opinion a while back, but the upstream libraries I depend on, namely zlib and bzip2, have been very quiet (zlib will soon be three years since the last release, bzip2 was effectively dead until recently). I already include patches for Bzip2, so a few more aren't a problem.

However, if you are able to submit patches for the warnings being emitted by those files maintained by p5p (e.g., perl.c, util.c), we would be happy to consider them.

And patches for bzip2 will also be considered.

Just noticed that my email reply to this issue on P5P didn't make it into the github comments. Above is a cut-n-paste from P5P. Is this a bug/feature/limitation?

@Grinnz
Copy link
Contributor

Grinnz commented Nov 21, 2019

Email replies to perlbug-followup no longer go anywhere useful (I believe the mailbox is manually monitored).

@pmqs
Copy link
Contributor

pmqs commented Nov 21, 2019

Email replies to perlbug-followup no longer go anywhere useful (I believe the mailbox is manually monitored).

That's a shame

pmqs added a commit to pmqs/Compress-Raw-Zlib that referenced this issue Nov 23, 2019
bingos added a commit that referenced this issue Nov 24, 2019
  [DELTA]

  2.091 23 November 2019

      * Silence "macro expands to multiple statements" warning
        Change sourced upstream from #17013
        pmqs/Compress-Raw-Zlib#2
        da2bd1fc765b80d01ed10a79b6c4a035e5095ed8
@pmqs
Copy link
Contributor

pmqs commented Nov 25, 2019

I've updated Compress-Raw-Zlib and Compress-Raw-Bzip2 to address all the warnings from this ticket. Fix is in version 2.091 of both modules.

@jkeenan
Copy link
Contributor

jkeenan commented Nov 25, 2019

@pmqs, thanks for your attention to this. Your work has led to a dramatic reduction in the number of build-time warnings we're getting from gcc-8.

$ report-build-warnings make.d2e1c851.linux.gcc8.output.txt
File:  make.d2e1c851.linux.gcc8.output.txt

  Wmaybe-uninitialized                       2
  Wunused-variable                           4

(And none of the remaining warnings are in your scope.)

Thank you very much.
Jim Keenan

@jkeenan jkeenan closed this as completed Nov 25, 2019
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 27, 2019
  2.091 23 November 2019

      * Silence "macro expands to multiple statements" warning
        Change sourced upstream from Perl/perl5#17013
        pmqs/Compress-Raw-Zlib#2
        da2bd1fc765b80d01ed10a79b6c4a035e5095ed8

  2.090 9 November 2019

      * No Changes

  2.089 3 November 2019

      * No Changes

  2.088 31 October 2019

      * Add SUPPORT section
        d348ad76c2073a2973d094891fbd0c2e24bf397d

      * 000prereq.t: dump Perl version
        e1afe502818cb1ccf5bad917b14b029b408f47f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 type-core
Projects
None yet
Development

No branches or pull requests

5 participants