Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: src/utils.h

Issue 2258473002: Added static assert to BitField to ensure the contents fit within the field (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index f95a136f96e6b0494057193d9f2da28e4faa8b86..a58439971f4c1f5ac291c7188a703a5b404946e3 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -305,8 +305,9 @@ class BitFieldBase {
static T decode(U value) {
return static_cast<T>((value & kMask) >> shift);
}
-};
+ STATIC_ASSERT((kNext - 1) / 8 < sizeof(U));
Jakob Kummerow 2016/08/17 15:47:01 How about: STATIC_ASSERT(kNext / kBitsPerByte <=
+};
template <class T, int shift, int size>
class BitField8 : public BitFieldBase<T, shift, size, uint8_t> {};
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698