ebu / libadm

Audio Definition Model (ITU-R BS.2076) handling library
https://libadm.readthedocs.io
Apache License 2.0
39 stars 16 forks source link

Fix warnings #161

Closed tomjnixon closed 2 years ago

tomjnixon commented 2 years ago

fix a few warnings when compiling with gcc and clang

This misses a few warnings like this from gcc (not clang):

/home/thomasn/dev/audio/libadm/src/private/rapidxml_formatter.cpp:36:24: warning: ‘*((void*)(& cartesianPosition)+20).adm::detail::NamedType<float, adm::ZOffsetTag>::value_’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |           node.setValue(element.get());
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/home/thomasn/dev/audio/libadm/src/private/rapidxml_formatter.cpp:565:14: note: ‘*((void*)(& cartesianPosition)+20).adm::detail::NamedType<float, adm::ZOffsetTag>::value_’ was declared here
  565 |         auto cartesianPosition =
      |              ^~~~~~~~~~~~~~~~~

I can't quite figure out the cause of this. boost::optional<T>::get just asserts that there is a value (doesn't throw an exception), so PositionOffset::get<ZOffset> can return an uninitialised value, but this code doesn't return unless has returns true, so that never happens.

I suspect the compiler just gives up trying to work out what's happening in this specific case (lots of templates). Throwing an exception in OptionalParameter::get if the optional is empty seems to solve this, and would probably be a good idea, but it's a fairly big change to apply this to the non-auto-base types too.

codecov-commenter commented 2 years ago

Codecov Report

Merging #161 (c94bea3) into master (0fe31b0) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #161   +/-   ##
=======================================
  Coverage   89.43%   89.43%           
=======================================
  Files         125      125           
  Lines        5667     5667           
=======================================
  Hits         5068     5068           
  Misses        599      599           
Impacted Files Coverage Δ
include/adm/detail/id_map.hpp 100.00% <ø> (ø)
include/adm/private/rapidxml_utils.hpp 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more