projects
/
gem5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a3d3eb0
)
base: Add a static assert to check bit union ranges
author
Andreas Sandberg
<Andreas.Sandberg@ARM.com>
Tue, 26 Aug 2014 14:13:28 +0000
(10:13 -0400)
committer
Andreas Sandberg
<Andreas.Sandberg@ARM.com>
Tue, 26 Aug 2014 14:13:28 +0000
(10:13 -0400)
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.
src/base/bitunion.hh
patch
|
blob
|
history
diff --git
a/src/base/bitunion.hh
b/src/base/bitunion.hh
index f640fa3b19275b3d77400037312bc5453cdf870f..190c1a5e13d6dfa74617013a48e301087ea83a0f 100644
(file)
--- a/
src/base/bitunion.hh
+++ b/
src/base/bitunion.hh
@@
-85,6
+85,9
@@
namespace BitfieldBackend
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
{