[build2] build2 staging GCC 11 compiler warnings

Matthew Krupcale mkrupcale at matthewkrupcale.com
Wed Jan 20 21:40:09 UTC 2021


Hello,

I built[1] the latest build2 staging, and there are a couple new GCC
11 compiler warnings (probably due to compiler updates since these
parts of the build2 code are relatively old). The first is an ODR
violation[2]:

ld bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/exe{bpkg}
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/fetch.cxx:525:8:
warning: type 'kind' violates the C++ One Definition Rule [-Wodr]
  525 |   enum kind {wget, curl, fetch};
      |        ^
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/checksum.cxx:230:14:
note: a type with different signedness is defined in another
translation unit
  230 |   enum class kind {sha256, sha256sum, shasum};
      |              ^
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/fetch.cxx:525:8:
warning: type 'bpkg::kind' violates the C++ One Definition Rule
[-Wodr]
  525 |   enum kind {wget, curl, fetch};
      |        ^
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/checksum.cxx:230:14:
note: an enum with different value name is defined in another
translation unit
  230 |   enum class kind {sha256, sha256sum, shasum};
      |              ^
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/fetch.cxx:525:14:
note: name 'wget' differs from name 'sha256' defined in another
translation unit
  525 |   enum kind {wget, curl, fetch};
      |              ^
/builddir/build/BUILD/build2-toolchain-0.14.0/bpkg-0.14.0-a.0.20210108084446.5b43d1ef9191/bpkg/checksum.cxx:230:20:
note: mismatching definition
  230 |   enum class kind {sha256, sha256sum, shasum};
      |                    ^

It appears that there are two bpkg::kind enums defined.

Secondly, there are also several new -Wfree-nonheap-object warnings[2]
related to libbutl/small-allocator.mxx:small_allocator::deallocate,
but I believe these are false positives[3] since operator delete is
only conditionally called. (GCC 11 added[4] support for this warning
with operator delete).

On the plus side, I'm no longer seeing any -Wmaybe-uninitialized
warnings[5], so perhaps GCC made improvements there.

Best,
Matthew

[1] https://copr.fedorainfracloud.org/coprs/mkrupcale/build2/build/1889883/
[2] https://download.copr.fedorainfracloud.org/results/mkrupcale/build2/fedora-rawhide-x86_64/01889883-build2/builder-live.log.gz
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202
[4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57111
[5] https://download.copr.fedorainfracloud.org/results/mkrupcale/build2/fedora-rawhide-x86_64/01565619-build2/builder-live.log.gz



More information about the users mailing list