Enforce unsigned type in flags.
authorKevin Boyd <kevin44boyd@gmail.com>
Wed, 8 Jul 2020 11:31:20 +0000 (11:31 +0000)
committerChristian Blau <cblau.mail@gmail.com>
Wed, 8 Jul 2020 11:31:20 +0000 (11:31 +0000)
commit9aa69be648e48966ca18bed61d6d84d37a65bd11
treef7efdd878c2c76352a5baf1abce1534609078543
parent99a5aa62d701020f27bc4087a8f5f0b0e504f29a
Enforce unsigned type in flags.

Flag enums could be signed types - since the only operations performed
by the flags were bit ops, this was harmless, but the implicit signed/
unsigned conversions are caught in analysis tools like UBSAN that can
also catch real issues.

Added a compile-time enforcement of underlying unsigned type to the
flags class, and specified uint64_t for underlying type of the class
and the various flags that are passed to it.

Added some SFINAE to disable accidental instantiation of non-enum
types - before C++ 20 std::underlying_type on a non-enum is undefined.
src/gromacs/analysisdata/dataframe.h
src/gromacs/options/optionflags.h
src/gromacs/selection/selectionenums.h
src/gromacs/selection/tests/selectioncollection.cpp
src/gromacs/utility/flags.h