Skip to content

Sync with downstream Perl source: silence uninitialized warnings & building with C++

Paul Marquess requested to merge pmqs/bzip2:master into master

Downstream the Perl project includes a sub-set of bzip2 sources via the module Compress-Raw-Bzip2.

An ongoing task in the Perl community is focused on eliminating all compiler warnings from the Perl source tree.

Uninitialized warnings

The first change changes in this MR are included in the perl copy of compress.c and silence a few uninitialised-type warnings (mostly, but not exclusively, with gcc7)

$ gcc-7 -c  -I..  -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O3   -Wall -Wno-comment  -DBZ_NO_STDIO  ../compress.c
../compress.c: In function ‘sendMTFValues’:
../compress.c:243:19: warning: variable ‘nBytes’ set but not used [-Wunused-but-set-variable]
    Int32 nGroups, nBytes;
                   ^~~~~~
../compress.c: In function ‘BZ2_compressBlock’:
../compress.c:391:54: warning: ‘cost[5]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
                                                      ^~
../compress.c:256:11: note: ‘cost[5]’ was declared here
    UInt16 cost[BZ_N_GROUPS];
           ^~~~
../compress.c:401:21: warning: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (cost[t] < bc) { bc = cost[t]; bt = t; };
                 ~~~~^~~
../compress.c:256:11: note: ‘cost[3]’ was declared here
    UInt16 cost[BZ_N_GROUPS];
           ^~~~
../compress.c:401:21: warning: ‘cost[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (cost[t] < bc) { bc = cost[t]; bt = t; };
                 ~~~~^~~
../compress.c:256:11: note: ‘cost[2]’ was declared here
    UInt16 cost[BZ_N_GROUPS];
           ^~~~

Most of this change is based on the downstream MR https://github.com/pmqs/Compress-Raw-Bzip2/pull/5 (see also https://github.com/pmqs/Compress-Raw-Bzip2/issues/4 and https://github.com/Perl/perl5/issues/19432)

Also - a sub-set of this was reported yesterday in the bzip2 sourceware bugzilla at https://sourceware.org/bugzilla/show_bug.cgi?id=28904 - not sure if that is active anymore?

Build with C++

Added another change that allows the sub-set of bzip2 files used by Perl to build with a C++ compiler (Perl can optionally be built with a C++ compiler.

This issue was originally reported in #29

Edited by Paul Marquess

Merge request reports