Skip to content

Add CaloIndex::Undefined enum value

Addresses a number of undefined behaviour sanitizer errors, e.g.

https://lhcb-nightlies.web.cern.ch/logs/tests/nightly/lhcb-sanitizers/464/x86_64-centos7-gcc9-dbg+ubsan/Brunel/

/cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/9.2.0-afc57/x86_64-centos7/include/c++/9.2.0/bits/stl_function.h:386:20: runtime error: load of value 4294967295, which is not a valid value for type 'CaloIndex'

These are caused by the fact in a number of places, -1 was statically cast to enum CaloCellCode::CaloIndex and the sanitizer (correctly) flags this as undefined behaviour due to the fact -1 did not correspond to a defined value for the enum.

Solution is simple. Acknowledge that a undefined state for the enum is required, and add one.

Edited by Christopher Rob Jones

Merge request reports