From 738aa17493c2e6259b75548cd395c8392d516e01 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 21 Jan 2021 10:11:54 +0000 Subject: [PATCH] EnumMaskIterator: ASSERT when the mask is too big. This will catch errors when someone updates an enum used with EnumMaskIterator without updating EnumBitmaskSize. Previously it would just ignore the extra bits, which produced super confusing bugs. Bug: dawn:635 Change-Id: Ib0bf3f252db317a1bfdeb687b2426801a79b524d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38260 Commit-Queue: Corentin Wallez Reviewed-by: Stephen White Reviewed-by: Austin Eng Auto-Submit: Corentin Wallez --- src/dawn_native/EnumMaskIterator.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dawn_native/EnumMaskIterator.h b/src/dawn_native/EnumMaskIterator.h index 85fde1032d..75d639da0d 100644 --- a/src/dawn_native/EnumMaskIterator.h +++ b/src/dawn_native/EnumMaskIterator.h @@ -29,6 +29,8 @@ namespace dawn_native { public: EnumMaskIterator(const T& mask) : mBitSetIterator(std::bitset(static_cast(mask))) { + // If you hit this ASSERT it means that you forgot to update EnumBitmaskSize::value; + ASSERT(U(mask) == 0 || Log2(uint64_t(U(mask))) < N); } class Iterator final {