changeset 4593282280e4 in /z/repo/gem5 details: http://repo.gem5.org/gem5?cmd=changeset;node=4593282280e4 description: base: Add a static assert to check bit union ranges
If a bit field in a bit union specified as Bitfield<LSB, MSB> instead of Bitfield<MSB, LSB> the code silently fails and the field is read as zero. This changeset introduces a static assert that tests, at compile time, that the bit order is correct. diffstat: src/base/bitunion.hh | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diffs (13 lines): diff -r e475a7861078 -r 4593282280e4 src/base/bitunion.hh --- a/src/base/bitunion.hh Tue Aug 26 10:13:23 2014 -0400 +++ b/src/base/bitunion.hh Tue Aug 26 10:13:28 2014 -0400 @@ -85,6 +85,9 @@ template<int first, int last=first> class Bitfield : public BitfieldBase<Type> { + static_assert(first >= last, + "Bitfield ranges must be specified as <msb, lsb>"); + public: operator const uint64_t () const { _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev